I have a WPF DataGrid that has another datagrid declared within the RowDetailsTemplate;
<DataGrid name="dataGrid1" RowDetailsVisibilityMode="VisibleWhenSelected">
...
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid name="dataGrid2">
...
</DataGrid/>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
When I CTRL-Click a row on the child DataGrid, it un-selects the parent datagrid's SelectedItem
and hides the RowDetailsTemplate
.
I assume this is some kind of Routed Event behaviour, but I've tried to catch MouseDown
/LeftButtonMouseDown
on the datagrid but no event is fired. I've also caught the SelectedItemChanged
event on the child datagrid and set e.Handled = true;
but the event still triggers on the parent.
How can I stop the parent datagrid from unselecting when CTRL-Clicking a child DataGridRow?
Catching
PreviewMouseLeftButtonDown
at the child control, settinge.Handled = true
anddataGridRow.IsSelected = !dataGridRow.IsSelected
fixed this.