WPF - How do I find the GridViewColumn from the Cell
Question
I have a WPf ListView that i am replacing the View with GridView to give me columns etc.
I want to apply a Cell Content Template to the Column and do a binding from the Cell template to the GridViewColumn (I have subclassed the column and it has some extra properties)
any ideas?
Solution
Well that should be pretty easy:
<GridViewColumn x:Name="myColumn" Header="My Header">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ElementName=myColumn, Path=Header}"
TextAlignment="Right" Width="auto"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
Just name your column and in the binding supply the name as ElementName and you will be able to bind to the properties of your column.
That should do the trick.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow