我看到了一个非常有趣的行为。如果我处理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”?