WPF Datagrid 双击 RowDetailsTemplate 也会触发父行上的双击事件
我有一个显示数据的 WPF Datagrid。对于 DataGrid 中显示的每个项目,可以展开该项目以显示使用 RowDetailsTemplate 显示的详细数据。 DataGrid Row 和 RowDetailsTemplate 都处理双击事件。
问题是,当双击 RowDetailsTemplate 时,双击事件被正确触发,但父行的双击事件也被触发。这是不受欢迎的行为。
有谁知道如何解决此问题,以便双击 RowDetailTemplate 仅触发 RowDetailsTemplate 双击事件,而不触发其父 Row 双击事件?
I have a WPF Datagrid showing data. For each item displayed in the DataGrid, the item can be expanded to display detail data shown using the RowDetailsTemplate. Both the DataGrid Row and the RowDetailsTemplate handle the Double Click event.
The problem is when double clicking on the RowDetailsTemplate, the double click event is correctly fired, but the double click event for the parent Row is ALSO fired. This is undesired behaviour.
Does anyone know how to resolve this so that double clicking on the RowDetailTemplate only fired the RowDetailsTemplate double click event and not also it's parent Row double click event?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到过这种情况并观察到两个事件,因此将 e.Handled 设置为 true 没有帮助。
我找不到比保留布尔“锁定”变量更好的解决方案:
I encountered this and observed two events, so setting e.Handled to true did not help.
I couldn't find a better solution than to keep a boolean 'lock' variable:
该事件可能正在冒泡,您可以尝试
在行详细信息中设置双击处理程序以防止父控件进行处理。
The event is probably bubbling, you could try setting
in the row details double click handler to prevent the handling by parent controls.