DataGrid event handling in MVVM

2019-09-06 13:55发布

I have a DataGrid and need to handle its events. I have a business logic to be implemented which needs to be handled in the ViewModel and able to unit test.

Can I raise events and handle them in the ViewModel? In this case how to unit test?

标签: wpf mvvm prism-4
1条回答
Bombasti
2楼-- · 2019-09-06 15:01

You can use EventTrigger from System.Windows.Interactivity or MvvmLight

<DataGrid x:Name="myProtokollList">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseDoubleClick">
            <i:InvokeCommandAction  Command="{Binding Path=OpenCommand}" CommandParameter="{Binding ElementName=myProtokollList, Path=SelectedItem.OriginalSatzX}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
查看更多
登录 后发表回答