1

This bigger code example below works. Now what I really want to route is the GridViewColumnHeader.Click event within the EventTrigger. Replacing MouseMove with GridViewColumnHeader.Click doesn't work. Any ideas on that?

<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>
Noctis
  • 11,507
  • 3
  • 43
  • 82
timmkrause
  • 3,367
  • 4
  • 32
  • 59
  • GridViewColumnHeader.Click ? – eran otzap Nov 20 '13 at 15:11
  • Yes. It is executed when I click on the header of the column. I'd like to initiate a sort then. – timmkrause Nov 20 '13 at 15:26
  • You can try with attached behaviors like Dan Parsonson suggests [in this answer](http://stackoverflow.com/a/8057736/1698987). – Noctis Nov 22 '13 at 01:23
  • 1
    the datagrid supports sorting Add SortMemberPath="PropertyA" to the colmn declaration. Is sorting the only thing you want to accomplish with the header click? – J King Nov 25 '13 at 22:25
  • Thanks for your hint. Ended up using the DataGrid instead which supports sorting too via a CanUserSortColumns property (enabled by default). – timmkrause Nov 26 '13 at 09:54

1 Answers1

2

I used the DataGrid instead which supports sorting by default.

timmkrause
  • 3,367
  • 4
  • 32
  • 59