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>
2
  • You want to use the control itself or the contents of the header as a parameter? Commented May 4, 2015 at 7: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. Commented May 4, 2015 at 7:35

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

1 Comment

may be helpfull: ((Binding)((GridViewColumnHeader)parameter).Column.DisplayMemberBinding).Path.Path;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.