Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
840
Lingering selection issue in XamDataGrid
posted

I've got a XamDataGrid bound to some view models using MVVM.  In our scenario, we only ever want a single row selected.  We're using all the obvious stuff like SelectionTypeRecord="Single", etc.

I've even gone so far as to hook into the dependency property callback for when the datasource for the list changes, or when the current selection changes.  The idea being that at that point I can explicitly remove any lingering selections by clearing out the SelectedItems collection in the control code behind and stuff.

Unfortunately, this does not work.  Even with the following code:

foreach (var selectedItem in xamDataGrid.Records)

{
selectedItem.IsSelected = false;
}

I can step through the debugger and look at the offending rows that aren't letting go of the selection.  When you get to one of those rows, "IsSelected" will be true.  After explicitly setting it to false, it will remain true.

Anyone have any ideas about what would be preventing SelectedItems from letting go of their selections?

Any ideas would be greatly appreciated.