This may (hopefully) have a trivial or very simple answer.
Suppose I want customized headings for my DataGrid
. I can use a DataTemplate
as so:
<DataGridTextColumn Binding="{Binding Name}">
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="Header Text" TextWrapping="Wrap"/>
</DataTemplate>
</DataGridTextColumn.HeaderTemplate>
</DataGridTextColumn>
However, if there are many columns it is less cumbersome to be able to use something like
<DataGridTextColumn Binding="{Binding Name}">
HeaderTemplate="{StaticResource ColumnHeaderTemplate}"
</DataGridTextColumn>
where ColumnHeaderTemplate
is my custom DataTemplate
. My question is how do I pass the "Header Text" to the DataTemplate
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…