1

my question is: Is it possible to use a GridViewColumnHeader as a CommandParameter? I have the following code and I want to use the clicked ColumnHeader as the CommandParameter:

<GridViewColumn Width="Auto" DisplayMemberBinding="{Binding Path=Vorname}">
      <GridViewColumnHeader Content="Vorname" Command="{Binding Path=ColumnHeaderClickCommand}"/>
</GridViewColumn>
sac1
  • 1,344
  • 10
  • 15
Dennis Schröer
  • 2,392
  • 16
  • 46
  • You want to use the control itself or the contents of the header as a parameter? – VidasV May 04 '15 at 07:10
  • Thank you for your answer, it helped me a lot! I only need the clicked ColumnHeader as a parameter. I have access to the list itself in my Viewmodel. – Dennis Schröer May 04 '15 at 07:35

1 Answers1

1

If ColumnHeaderClickCommand is an ICommand:

<GridViewColumn Width="Auto" DisplayMemberBinding="{Binding Path=Vorname}">
     <GridViewColumnHeader Content="Vorname" Command="{Binding Path=ColumnHeaderClickCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}"/>
</GridViewColumn>
sac1
  • 1,344
  • 10
  • 15
  • may be helpfull: ((Binding)((GridViewColumnHeader)parameter).Column.DisplayMemberBinding).Path.Path; – heringer Jul 15 '15 at 19:18