In my WPF project I have a custom control with some properties assigned, they are of "string" and "bool" types. Something like:
public class CustControl : Control
{
static CustControl()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustControl), new FrameworkPropertyMetadata(typeof(CustControl)));
}
public readonly static DependencyProperty CustNoProperty = DependencyProperty.Register("CustNo", typeof(string), typeof(CustControl), new PropertyMetadata(""));
public string CustNo
{
get { return (string)GetValue(CustNoProperty); }
set { SetValue(CustNoProperty, value); }
}
public readonly static DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(CustControl), new PropertyMetadata(false));
public bool IsSelected
{
get { return (bool)GetValue(IsSelectedProperty); }
set { SetValue(IsSelectedProperty, value); }
}
....
}
Now I have to add here a property for choosing a string value from a predefined set of values, let's say, "Red", "Green", "Yellow", "Black".
What is the correct way to do this?