WPF ListBox SelectedItems TwoWay Binding

1 · Alexey Golub · Nov. 1, 2016, midnight
For some unclear reasons, WPF’s ListBox control does not allow two-way binding on SelectedItems property the way it does with SelectedItem. This could have been very useful when using multi-select to bind the whole list of selected items to the view model. Interestingly, you can still call Add(), Remove(), Clear() methods on ListBox.SelectedItems which updates the selection correctly, so it just comes down to implementing a behavior that makes the property bindable. Behavior implementation Here…...