下面这个更大的代码示例有效。现在我真正想要路由的是GridViewColumnHeader.Click
内的EventTrigger
事件。用MouseMove
替换GridViewColumnHeader.Click
不起作用。有什么想法?
<ListView ItemsSource="{Binding MyCollection}"
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseMove">
<cmd:EventToCommand
Command="{Binding FooCommand, Mode=OneWay}"
CommandParameter="{Binding}"
MustToggleIsEnabledValue="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListView.View>
<GridView>
<GridViewColumn Header="ColumnA"
DisplayMemberBinding="{Binding PropertyA}"></GridViewColumn>
<GridViewColumn Header="ColumnB"
DisplayMemberBinding="{Binding PropertyB}"></GridViewColumn>
<GridViewColumn Header="ColumnC"
DisplayMemberBinding="{Binding PropertyC}"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
答案 0 :(得分:2)
我使用的是DataGrid,它默认支持排序。