跳转至

WPF_DataGrid双击单元格事件

添加命名空间

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

绑定按钮

<DataGrid x:Name="datagrid">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseDoubleClick">
            <i:InvokeCommandAction Command="{Binding Path=DoubleClickItemCommand}" CommandParameter="{Binding ElementName=datagrid,Path=SelectedItem}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</DataGrid>

后台ViewModel

public ICommand DoubleClickItemCommand { get; set; }

评论