WPF DataGrid双击命令+ INotifyPropertyChanged?

jav*_*red 4 c# wpf mvvm

我希望在单击DataGrid项时在我的ViewModel中执行一个命令.作为参数,我希望有相应的行.

我在互联网上找到了一种方法,但它使用了 DependencyProperty

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/632ea875-a5b8-4d47-85b3-b30f28e0b827

我没有DependencyProperty在我的项目中使用,而是我正在使用INotifyPropertyChanged.如何实现"双击数据网格"commaind而不使用DependencyProperty

vid*_*oon 8

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
...
<DataGrid SelectedItem={Binding MySelectedItem, Mode=TwoWay}>
  <i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseDoubleClick">
        <i:InvokeCommandAction Command="{Binding YourCommand}" />
    </i:EventTrigger>
  </i:Interaction.Triggers>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)

  • 您需要添加以下引用:System.Windows.Interactivity.是的,这适用于C#. (2认同)