I have a combobox that is filled using the value of an enum.
ModeCb.ItemsSource = Enum.GetValues(typeof(ServerModes));
ModeCd.SelectedItem = Mode.JsonRpc;
public Enum ServerMode
{
JsonRpc,
HTML
};
public ServerMode SelectedMode {get; set;}
I want the change of value by user to the combobox to update the value of SelectedMode so I can check anytime I want what the selected item is without having to look at the ModeCb.SelectedItem each time (and avoid using dispatcher if multithreading)
my XAML looks like :
<ComboBox SelectedItem="{Binding _mode, Mode=OneWay}" />
I have tried all possible mode except for “OneTime” but none of them works.
If using TwoWay or OneWayToSource then the selected item in the combobox is cleared.
Using OneWay it is not.
I’ve tried to bind to SelectedIndex and SelectedValue instead but that does not work either.