WPF setting Style StaticResource in ViewModel
<p>I've a GridControl in WPF (it's from DevExpress but that's not really the point) and I'm trying to style the headers based on a <code>StaticResource</code>.</p>

<p>Normally what I could do is</p>

<pre><code>&lt;UserControl.Resources&gt;
    &lt;Style x:Key="HeaderStyle" TargetType="dxg:HeaderContentControl"&gt;
        &lt;Setter Property="FontWeight" Value="Bold" /&gt;
    &lt;/Style&gt;
&lt;/UserControl.Resources&gt;

&lt;dxg:GridControl x:Name="MyParameters" ItemsSource="{Binding ParamRows}"&gt;
    &lt;dxg:GridColumn ColumnHeaderContentStyle="{StaticResource HeaderStyle}" x:Name="ParamName" FieldName="ParamName" Width="80" Header="Parameter" /&gt;
    &lt;dxg:GridColumn ColumnHeaderContentStyle="{StaticResource HeaderStyle}" x:Name="ParamValue" Binding="{Binding ParamValue}" Width="50"  Header="Value" /&gt;
&lt;!-- etc.  --&gt;
</code></pre>

<p>..and that would work fine.</p>

<p>However, I'm building the columns dynamically in the ViewModel so I need to be able to set the <code>ColumnHeaderContentStyle</code> programmatically at run-time.</p>

<p>So the XAML has...</p>

<pre><code>&lt;dxg:GridControl x:Name="Parameters" ItemsSource="{Binding ParamRows}" ColumnsSource="{Binding ParamColumns}"&gt;
    &lt;!-- no list of rows.  --&gt;
</code></pre>

<p>... and in the C# Code...</p>

<pre><code>ParamColumns.Add(new GridColumn
{
    ColumnHeaderContentStyle = (Style)Application.Current.Resources["HeaderStyle"],
    FieldName = "ParamName",
    Width=80,
    Header="Parameter"
});


ParamColumns.Add(new GridColumn
{
    ColumnHeaderContentStyle = (Style)Application.Current.Resources["HeaderStyle"],
    Binding = new Binding("ParamValue"),
    Width=50,
    Header="Value"
});
</code></pre>

<p>A bit of research pointed me to using <code>Application.Current.Resources["HeaderStyle"]</code>, however it returns <code>null</code> and so the style isn't applied to the header.</p>

<p>What am I doing wrong here?</p>