As an example take the following code:
public enum ExampleEnum { FooBar, BarFoo }
public class ExampleClass : INotifyPropertyChanged
{
private ExampleEn
I prefer not to use the name of enum in UI. I prefer use different value for user (DisplayMemberPath
) and different for value (enum in this case) (SelectedValuePath
). Those two values can be packed to KeyValuePair
and stored in dictionary.
XAML
C#
public Dictionary ExampleEnumsWithCaptions { get; } =
new Dictionary()
{
{ExampleEnum.FooBar, "Foo Bar"},
{ExampleEnum.BarFoo, "Reversed Foo Bar"},
//{ExampleEnum.None, "Hidden in UI"},
};
private ExampleEnum example;
public ExampleEnum ExampleProperty
{
get { return example; }
set { /* set and notify */; }
}
EDIT: Compatible with the MVVM pattern.