Using TemplateBinding in DataGridTemplateColumn DataTemplate Doesn't appear to work.

Nov 5, 2009 at 1:10 PM


I'm very new to WPF, and the WPF ToolKit.  I'd appreciate some advice and help please.

I am using the WPF ToolKit DataGrid, and I wanted to re-use a DataTemplate for several DataGridTemplateColumns (checkbox style columns) where the only difference between the them is where the path for IsChecked data binding is sourced (different property on LINQ to SQL entity class).  I found the DataGridCheckBoxColumn too restrictive and I want to change the cell's style with a DataTrigger.  This works fine.  However I thought I could use DataTriggers to change the binding path of the checkbox based on the column's header property, making use of the RelativeSource TemplateBinding.  This doesn't appear to work for me, and I found this discussion,, indicating it's a known issue and would be fixed in v1.  The example shown in the link is very similar to what I would like to achieve.

I tried to verify whether it is the way I am implementing it or a bug, so I added an extra DataGridTemplateColumn that simply binds a TextBlock's text to the column's Header attribute.  This doesn't work either.

                    <my:DataGridTemplateColumn Header="Test this binding">




                                    <TextBlock Text="{Binding Path=Header, RelativeSource={RelativeSource TemplatedParent}}"/>





Can anyone tell me whether this is really an issue, or if I've got it wrong please?  Also can anyone provide a better way to achieve what I was trying to do, or a simple workaround please?