I have a grid with IsSynchronizedWithCurrentItem set to true and is bind to an ICollectionView. I have SelectionTypeRecord="Single" so only one record can be selected at a time.
I am programatically moving the CurrentItem of this view. While ActiveRecord is reset accordingly, issue is that XamDataGrid.SelectedItems.Records is not. SelectedItems not changed when changing ActiveRecord.
So to clear an active record I would have to do two steps:
_viewModel.DataKeysView.MoveCurrentTo(null); dataKeysGrid.SelectedItems.Records.Clear();
And to select record (for example):
_viewModel.DataKeysView.MoveCurrentToLast(); dataKeysGrid.Records[count - 1].IsSelected = true;
Is there any better way of doing this? Is there a way to @automatically@ synchronize selected item when changing an active record.
Thanks in advance.
Hello,
Settings by IsSynchronizedWithCurrentItem property of the XamDataGrid will synchronize the ActiveRecord of the XamDataGrid with the CurrentItem of the ICollectionView. This is by design.
Please note that the active record does not mean that it is selected. A record can be selected by clicking on the records selector, holding the shift/ctrl key or by clicking on a cell (when the CellClickAction is set to Select Record).
If you want to select the active record, you can handle the RecordActivated event and select the record that has been activated.
Handling this event and setting e.IsSelected = true seems to break multi select... how can I handle this and also allow for multiple selections? I also have my cellclickaction as full record select.
Thanks.
I am still unclear why one would active one record with intend to select another record (specifically with single record selection mode SelectionTypeRecord="Single") but I will use the event handler as you suggested so to select the activated record.