I have 2 ComboBoxes
whose ItemsSource
is bound to the same ObservableCollection
:
public ObservableCollection<MyType> MyTypeCollection { get; set; }
I have defined 2 different SelectedItem
properties which in turn are bound to the correct ComboBox
.
public MyType MySelectedItem1 { get; set; }
public MyType MySelectedItem2 { get; set; }
Whenever I select an item in one of the ComboBoxes
, both SelectedItem
properties defined in my class are set to that selection. Both ComboBoxes
are also set visually to that value.
Why is this?
I tried several things like Mode=OneWay
etc, but it's not working.
Here's my XAML (trimmed down for the question):
<ComboBox SelectedItem="{Binding MySelectedItem1}"
ItemsSource="{Binding MyTypeCollection, Mode=OneWay}"/>
<ComboBox SelectedItem="{Binding MySelectedItem2}"
ItemsSource="{Binding MyTypeCollection, Mode=OneWay}"/>