In my project I need to bing the following enum
public enum eFlex_IO_COMP_CM
{
ePan = 0,
eComp = 1,
}
into a combobox. I've a public list, valorized as follows:
public IEnumerable<eFlex_IO_COMP_CM> EnumFlexIoCompCm { get; set; }
EnumFlexIoCompCm = Enum.GetValues(typeof(eFlex_IO_COMP_CM)).Cast<eFlex_IO_COMP_CM>();
This is the XAML code:
<ComboBox
Grid.Column="20"
Width="50"
ItemsSource="{Binding Path=EnumFlexIoCompCm, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ViewerFlexConfig}}"
SelectionChanged="Combo_SelectionChanged"
DisplayMemberPath="Value"
SelectedValuePath="Key"
SelectedValue="{Binding ConfigObject.COMP_CounterMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>
Basically I want to display the name of enum's item and set the key as value because I need to store in the database the int and not the description. The problem is that I cannot even display the name of enum's item and set correctly the value, as If I try to save, the value from that combobox is name. Any helps?