如何使用EventToCommand和MVVM Light路由GridViewColumnHeader.Click事件

时间:2013-11-20 14:59:16

标签: wpf command mvvm-light eventtocommand

下面这个更大的代码示例有效。现在我真正想要路由的是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>

1 个答案:

答案 0 :(得分:2)

我使用的是DataGrid,它默认支持排序。