Skip to content

πŸ’Ύ Enums

mrousavy edited this page Aug 21, 2018 · 2 revisions

The enum binding source extension allows for better binding support on enums.

Just use the EnumBindingSource extension to bind an enum to any ItemsSource:

<ComboBox ItemsSource="{Binding Source={jellyfish:EnumBindingSource {x:Type local:Status}}}"
	  SelectedItem="{Binding SelectedStatus}" />

It even allows Description support:

[TypeConverter(typeof(EnumDescriptionTypeConverter))]
enum Status
{
    [Description("Everything went fine")]
    Ok,
    [Description("Everything went horribly wrong")]
    Error
}

Result:

Demo Screenshot

Clone this wiki locally