【问题标题】:How to handle WPF Datagrid double click without using code behind如何在不使用代码的情况下处理 WPF Datagrid 双击
【发布时间】:2010-11-27 01:42:00
【问题描述】:

我们在这个项目中使用 Views 和 ViewModels,因此我们试图在 View 的代码隐藏中尽可能少。

我正在尝试将 WPFToolkit DataGridMouseDoubleClick 事件与同一视图中的 Button 已在使用的相同代码绑定。

Button 声明如下:

<Button Content="Select" cmd:ButtonBaseExtensions.Command="{Binding CommandViewEmployer}"/>

这意味着它在 ViewModel 中运行 CommandViewEmployer 属性。如何让 Grid MouseDoubleClick 运行相同的属性?我尝试添加MouseDoubleClick="{Binding CommandViewEmployer}",但出现错误。

我试图在尽可能少的代码隐藏中实现这一点,最好不要。

【问题讨论】:

  • ButtonBaseExtensions.Command 似乎是一个附加属性。你为什么不改变是在任何元素(而不仅仅是按钮)上处理 DoubleClick ?

标签: wpf mvvm datagrid mouseevent wpftoolkit


【解决方案1】:

您可以使用 Marlon Grech 的 attached command behaviors 之类的东西。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 2016-07-11
    • 2016-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多