0

I am using couple of DataGridTemplateColumns in my XAML DataGrid, each one of which is group of text boxes, since I wanted a grouped header layout for the columns (e.g. merged columns as headers in excel).

All of this works fine, since I am using the HeaderStyle property of the column to load a StaticResource for Style that defines a Grid layout and implements the grouped headers.

The issue is, the Header property of the DataGridTemplateColumn needs to be bound to a model member (or a StaticResource ?), since that will contain a string value that will be used in a ContentPresenter, which is part of the HeaderStyle. The ContentPresenter in the Style resource is defined as follows:

<ContentPresenter Grid.Row="2" Content="{TemplateBinding Content}"
VerticalAlignment="Center" HorizontalAlignment="Center"
Grid.ColumnSpan="11">

But this doesn't work. It only works if Header="SomeString, but as soon as I change it to Header="{Binding Something}" or Header="{StaticResource SomeResource}" it just shows a blank header.

Am I missing something here ?

DancingJohn
  • 557
  • 1
  • 9
  • 17

1 Answers1

0

Remove Content="{TemplateBinding Content}" as this is incorrect. The ContentPresenter will implicitly use the content supplied to it as part of the template

Dean Chalk
  • 20,076
  • 6
  • 59
  • 90
  • I see, though that isn't solving the problem. To be precise, the `DataGridTemplateColumn` is defined as follows `` – DancingJohn Apr 23 '13 at 13:12