How to get DataGridTemplateColumn Header Binding working?
<p>A <code>Window</code> contains some elements plus a <code>DataGrid</code>. The <code>DataContext</code> of the <code>Window</code> is set to a <code>ViewModel</code>, and the <code>DataGrid</code> is bound to a <code>Property</code> of the <code>ViewModel</code>:</p>

<pre><code>&lt;DataGrid ItemsSource="{Binding FilteredMessages}" AutoGenerateColumns="False" &gt;
</code></pre>

<p>Now I'd like to bind the <code>Header</code>s of the <code>Column</code>s to properties of the <code>ViewModel</code>, like e.g.:</p>

<pre><code>        &lt;DataGrid.Columns&gt;
            &lt;DataGridTemplateColumn Header="{Binding TimeColumnHeaderText}" Width="Auto" IsReadOnly="True"&gt;
                &lt;DataGridTemplateColumn.CellTemplate&gt;
                    &lt;DataTemplate&gt;
                        &lt;TextBlock Text="{Binding (logging:LogMessage.Time), StringFormat=\{0:yyyy-MM-dd HH:mm:ss.fff\}}"/&gt;
                    &lt;/DataTemplate&gt;
                &lt;/DataGridTemplateColumn.CellTemplate&gt;
            &lt;/DataGridTemplateColumn&gt;
</code></pre>

<p>While the contents of the grid is shown correctly, the Header fails to bind.</p>

<p>I've found a description of a BindingProxy at <a href="http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/" rel="nofollow">http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/</a> but failed to get it working. That solution requires a Resource in the DataGrid</p>

<pre><code>        &lt;DataGrid.Resources&gt;
            &lt;wpfUtilities:BindingProxy x:Key="proxy" Data="{Binding}" /&gt;
        &lt;/DataGrid.Resources&gt;
</code></pre>

<p>and a reference to that proxy in the <code>Binding</code> clause:</p>

<pre><code>&lt;DataGridTemplateColumn Header="{Binding TimeColumnHeaderText, Source={StaticResource proxy}}" Width="Auto" IsReadOnly="True"&gt;
</code></pre>

<p>I replaced <code>{Binding}</code> in the resources section with <code>{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}</code> but the property is not found on the proxy:</p>

<pre><code>BindingExpression path error: 'TimeColumnHeaderText' property not found on 'object' ''BindingProxy' 
</code></pre>

<p>Also tried to move the proxy to the resources section of the window, didn't help either.</p>