I try to use an enumeration type as a dependency property in my custom control, but always get an error:
public enum PriceCategories
{
First = 1,
Second = 2,
Third = 3,
Fourth = 4,
Fifth = 5,
Sixth = 6
}
public static readonly DependencyProperty PriceCatProperty =
DependencyProperty.Register("PriceCat", typeof(PriceCategories), typeof(CustControl), new PropertyMetadata(PriceCategories.First));
};
public PriceCategories PriceCat
{
get { return (PriceCategories)GetValue(PriceCatProperty); }
set { SetValue(PriceCatProperty, value); }
}
Please look. Where is the mistake?
source
share