I have a style being created in the xaml for my window which contains bindings to a DynamicResource:
<Window.Resources>
<local:RowColorConverter x:Key="RowColorConverter" />
<Style x:Key="OddEvenRowStyle">
<Setter Property="DataGridRow.Background">
<Setter.Value>
<Binding RelativeSource="{RelativeSource AncestorType=GroupItem}" Path="(ItemsControl.AlternationIndex)" Converter="{StaticResource RowColorConverter}">
<Binding.ConverterParameter>
<x:Array Type="Brush">
<SolidColorBrush Color="{DynamicResource RowPrimaryBrush}" />
<SolidColorBrush Color="{DynamicResource RowSecondaryBrush}" />
</x:Array>
</Binding.ConverterParameter>
</Binding>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
I then assign the style to a RowStyle for a DataGrid:
<DataGrid Name="dataGrid" AutoGenerateColumns="False" Height="Auto" Width="Auto" ItemsSource="{Binding}" RowStyle="{StaticResource OddEvenRowStyle}">
In the initialization of my window I'm assigning these DynamicResource values:
Resources["RowPrimaryBrush"] = Colors.LightGray;
Resources["RowSecondaryBrush"] = Colors.DarkGray;
However when I load up the window the colors aren't working correctly:
I'm pretty sure the rest of my code is okay because when I change the Color values in xaml to color values:
<x:Array Type="Brush">
<SolidColorBrush Color="LightGray" />
<SolidColorBrush Color="DarkGray" />
</x:Array>
The colors get assigned correctly:
Which is why I'm led to believe it's something to do with the bindings. Is there something wrong with the way I'm binding my colors?