This project is read-only.

Collapsing SelectedItem in DataGrid

Nov 25, 2014 at 3:52 AM
I'm using the DataGrid control in single selection mode, and if I click again on a currently selected item (item details are visible), then the item details do not collapse. This works flawlessly if the SelectionMode is set to Multiple.

From playing around with your sample app a bit, it looks like if SelectionMode=Single, then OnSelectionChanged does not fire if you click again on an already selected item. But if SelectionMode=Multiple, then clicking on the same item fires OnSelectionChanged with that item listed in the SelectionChangedEventArgs.RemovedItems property.

Is this is limitation of the underlying ListBox control itself? I noticed you're using your own derived version, MtListBox. Is this an enhancement you can add to that control?
Nov 25, 2014 at 5:07 PM
The DataGrid uses MtListBox internally which inherits from ListBox. So this limitation comes from ListBox because in this control you cannot deselect the selection too... Maybe its possible to add a MaximumSelectedItems property which can be set to 1 and which will provide this feature... Maybe i have the time to add this - this is just a hobby project...
Nov 25, 2014 at 5:30 PM
Ok, ive found a good solution... Coming soon
Nov 25, 2014 at 6:29 PM
Ok have a look at the bottom of and use version 2.3.18
Nov 26, 2014 at 7:05 AM
Works great! Thank you so much for incredibly quick fixes.