Databinding a ListBox with SelectionMode = Multiple

Posted by David Veeneman on Stack Overflow See other posts from Stack Overflow or by David Veeneman
Published on 2010-03-24T21:56:28Z Indexed on 2010/03/24 22:23 UTC
Read the original article Hit count: 566

Filed under:
|
|

I have a WPF ListBox that I would like to

  • Enable multiple selection in the ListBox, and
  • Databind the ListBox to my view model.

These two requirements appear to be incompatible. My view model has an ObservableCollection<T> property to bind to this ListBox; I set up a binding in XAML from the property to the ListBox.SelectedItems property. When I compiled, I got an error saying that the SelectedItems property was read only and could not be set from XAML.

Am I binding to the wrong control property? Is there a way to bind a multiple-selection ListBox in XAML to a view model collection property? Thanks for your help.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about listbox