The new xamDataGrid supports IsSynchronizedWithCurrentItem, but I didn't have a way to communicate multiple selections to my view model.
After piecing several forum posts together, I came up with this:
- Add an IsSelected property to your item view model:
public bool IsSelected { get; set; }
- Bind the DataRecordPresenter's IsSelected to your property:
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<Setter Property="IsSelected" Value="{Binding DataItem.IsSelected, Mode=TwoWay}"/>
</Style>
</igDP:XamDataGrid.Resources>
Now you can check your view models to see which ones are selected.
This doesn't seem very reliable because when you scroll the grid the records seem to lose their selected property.
Hi
Very new to binding and MVVM. can you please explain how to check to view model (datacontext) for the selected records?
Nick