WPF CommandParameter GridViewColumnHeader

时间:2015-05-04 06:46:54

标签: wpf xaml commandparameter

我的问题是:是否可以使用GridViewColumnHeader作为CommandParameter?我有以下代码,我想使用单击的ColumnHeader作为CommandParameter:

<GridViewColumn Width="Auto" DisplayMemberBinding="{Binding Path=Vorname}">
      <GridViewColumnHeader Content="Vorname" Command="{Binding Path=ColumnHeaderClickCommand}"/>
</GridViewColumn>

1 个答案:

答案 0 :(得分:1)

如果ColumnHeaderClickCommandICommand

<GridViewColumn Width="Auto" DisplayMemberBinding="{Binding Path=Vorname}">
     <GridViewColumnHeader Content="Vorname" Command="{Binding Path=ColumnHeaderClickCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}"/>
</GridViewColumn>