>< Window x:Class="ComboboxToEnumBinding.MainWindow" > xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" > xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > Title="MainWindow" Height="350" Width="525"> > > < Grid> > < ComboBox HorizontalAlignment="Center" > VerticalAlignment="Center" > Width="180" > ItemsSource="{Binding AvailableOptions}" > SelectedValue="{Binding SelectedOption}" /> > < /Grid> >< /Window> >>
>namespace ComboboxToEnumBinding >{ > using System; > using System.Collections.ObjectModel; > > public enum OptionsEnum > { > Standard = 1, > Mail = 2, > ZipX = 3 > } > > public partial class MainWindow > { > private OptionsEnum _selectedOption = OptionsEnum.Standard; > > private ObservableCollection<OptionsEnum> _availableOptions; > > public ObservableCollection<OptionsEnum> AvailableOptions > { > get > { > if (this._availableOptions == null) > { > this._availableOptions = new ObservableCollection<OptionsEnum>(); > foreach (OptionsEnum option in Enum.GetValues(typeof(OptionsEnum))) > { > this._availableOptions.Add(option); > } > } > > return this._availableOptions; > } > > set > { > this._availableOptions = value; > } > } > > public OptionsEnum SelectedOption > { > get > { > return this._selectedOption; > } > > set > { > this._selectedOption = value; > } > } > > public MainWindow() > { > InitializeComponent(); > this.DataContext = this; > } > } >} >Not sure an ObservableCollection serves much purpose with an enum - after all the enum is not going to change during execution ?