Search code examples
wpfcomboboxselectedvalue

wpf combobox - bind custom isselected property


I want to bind a list of items with properties 'ID', 'Description' and 'IsSelected' to a combobox. The display value is set using DisplayMemberPath to 'Description' which works fine. However i want that 'IsSelected' property to be set when that item is selected. I've tried Setting SelectedValuePath and SelectedValue to 'IsSelected' but it doesn't work.


Solution

  • The simplest solution would probably be to track the selected item in your view model, and keep it synced with the ComboBox by adding a two-way binding to SelectedItem. When the view model property changes, update the IsSelected property of the new and previous selections.