When I use the standard WPF DataGrid I can bind to the IsSelected property of the DataGridRow by doing the following.<DataGrid ItemsSource=”{Binding FindResults}” ...> <DataGrid.RowStyle> <Style TargetType=”{x:Type DataGridRow}”> <Setter Property”IsSelected” Value=”{Binding Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}” /> </Style> </DataGrid.RowStyle></DataGrid>The ItemSource of my DataGrid is FindResults which is a List<FindResult> and the FindResult has a bool Selected property. I would like to do something similar with the XamDataGrid. I have the following XAML so far.<igDP:XamDataGrid DataSource=”{WorkbenchRecords}” .....> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings.DataRecordPresenterStyle> <Style TargetType=”{x:Type igDP:DataRecordPresenter}” BasedOn=”{StaticResource {x:Type igDP:DataRecordPresenter}}”> <Setter Property=”IsSelected” Value=”{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}” /> </Style> </igDP:FieldLayoutSettings.DataRecordPresenterStyle> </igDP:XamDataGrid.FieldLayoutSettings></igDP:XamDataGrid>The DataSource of the XamDataGrid is WorkbenchRecords which is a List<WorkbenchRecord> and the WorkbenchRecord has a bool IsSelected property. I am not getting any binding errors but selecting rows the XamDataGrid is not setting the IsSelected property of my WorkbenchRecord to true.What is the best way to create a XAML binding the IsSelected property of my Workbench object?
Hello Eric,
As I have explained in the other forum thread, since the XamDataGrid has a Record virtualization Binding to IsSelected will work only for the Records in view, because when they are scrolled out the DataRecordPresentrer is Disposed. If you turn the virtualization off the binding will work. Also as stated here:
http://stackoverflow.com/questions/6430132/datagrid-isselected-binding-and-scrolling
the situation is the same in the MS DataGrid, when the virtualization is on the binding to IsSelected will broke once you scroll the Records.
Well I have looked at the other Thread you mentioned but I do not see a performance way to achieve this at this time. I ideal way to achieve this would be to bind to the IsSelected property just like you can with the standard WPF DataGrid. I am 99% sure this can deal with the virtualization issues when records are not visible and disposed. Although I have seen issues with the "select all" button on the WPF DataGrid (on the top left where the row and column headers meet).
I have tried dealing with this in the code-behind and the SelectedItemsChanging method. Using this approach I have to loop through all my records and force the IsSelected = false and then loop through all the e.NewSelection and set IsSelected = true. While this might work its looping through all the records so many times it will slow down when trying to deal with large record counts.
I love the XamDataGrid and the GroupBy capabilities but dealing with basic issues like selected items and MVVM is frustrating.
Why can't we just bind to IsSelected like the WPF DataGrid does?
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Thank you for your post. I have been looking into it and I can suggest you see this forum thread:
http://ko.infragistics.com/community/forums/t/62516.aspx
where it is explained how to achieve the functionality you want. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.