I have two seperate WPF Comboboxes both of them bind to the same object to populate their values. However, when I change the selection in one combobox, the selection in the other combobox is changed to the same as the first, and vice versa. This is not the behavior I want, I want only want to bind the content of the comboboxes to a single source without mirroring their selections. I am binding to a BindingList.To bind I use
ItemsSource="{Binding}"
and
comboBox1.DataContext = bindingList;
What do I need to do to unlink the selections of these two comboboxes?
The way these actually work bind the scenes is by wrapping the collection in an instance of ICollectionView
, which maintains the current selected item (amongst other things).
To get the behaviour you want, just set the DataContext of each combo box to:
new ListCollectionView(bindingList);