如何在MVVM上下文中处理DataGrid的DataGridTextColumn中的MouseUp事件?

时间:2016-03-04 11:05:10

标签: c# wpf mvvm datagrid prism

我看到了一个非常有趣的行为。如果我处理MouseDown的{​​{1}}事件DataGridTextColumn,那么我可以轻松调用DataGrid。 Hovever,我无法处理HelloCommand事件。在这种情况下,MouseUp不会被解雇。

HelloCommand

我尝试过使用<DataGrid ItemsSource="{Binding Persons}"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding FirstName}" > <DataGridTextColumn.HeaderTemplate> <DataTemplate> <Grid Background="Transparent"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseUp"> <!--EventName="MouseDown" handles perfectly--> <i:InvokeCommandAction Command="{Binding DataContext.HelloCommand, RelativeSource={RelativeSource AncestorType=Window}}"/> </i:EventTrigger> </i:Interaction.Triggers> <TextBlock Text="I am a TextBlock!:)"/> </Grid> </DataTemplate> </DataGridTextColumn.HeaderTemplate> </DataGridTextColumn> </DataGrid.Columns> </DataGrid> 。但是,它不会调用RoutedEventTrigger

Command

其中 <i:Interaction.Triggers> <helper:RoutedEventTrigger RoutedEvent="MouseUp"> <prism:InvokeCommandAction Command="{Binding GetNewDataCommand}" /> </helper:RoutedEventTrigger> </i:Interaction.Triggers>

helper:RoutedEventTrigger

如何处理public class RoutedEventTrigger : EventTriggerBase<DependencyObject> { RoutedEvent _routedEvent; ... } DataGridTextColumn事件的“MouseUp”?

0 个答案:

没有答案