How to bind SelectedItems property of multi-select enabled grid?

Dec 15, 2008 at 6:31 AM
I have a wpf datagrid where I have multi-select option for selecting rows.
Now i want to bind the SelectedItems property to a variable in my ViewModel to get the selections.
However there seems to be only a SelectedItem property on the grid which according to http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selecteditem.aspx
gives only the first item in case of multiple selection.

How do I get the multiple selections via databinding?
Dec 15, 2008 at 8:41 AM
Hi,

With multi-select DataGrids each DatGridRow has an IsSelected property which can be used to determine the current selection state. You can bind to this using a RelativeSource binding. See teh following example:

http://wpfadventures.wordpress.com/2008/11/26/multiselect-datagrid-with-checkboxes/

Regards,
Colin E.