我有一个
WPF DataGrid,它在RowDetailstemplate中声明了另一个datagrid;
<DataGrid name="dataGrid1" RowDetailsVisibilityMode="VisibleWhenSelected"> ... <DataGrid.RowDetailstemplate> <DataTemplate> <DataGrid name="dataGrid2"> ... </DataGrid/> </DataTemplate> </DataGrid.RowDetailstemplate> </DataGrid>
当我按CTRL-单击子DataGrid上的一行时,它取消选择父数据网格的SelectedItem并隐藏RowDetailstemplate.
我假设这是某种路由事件行为,但我试图在数据网格上捕获MouseDown / LeftButtonMouseDown但没有触发事件.我还在子数据网格上捕获了selecteditemchanged事件并设置了e.Handled = true;但事件仍会在父母身上触发.
当CTRL-单击子DataGridRow时,如何阻止父数据网格取消选择?
解决方法
在子控件上捕获PreviewMouseLeftButtonDown,设置e.Handled = true和dataGridRow.IsSelected =!dataGridRow.IsSelected修复此问题.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。