Hey,
So I have a WPF C# application that I am developing.
Currently I am working on a screen that should, on the left, display a list of objects.
Each of these objects has a "ResultState" field that should be used to determine the background colour of the item in the list.
I have created a ResultStateConverter that turns the value into a Brush and have added this as a resource into my window.
This is what my XMAL looks like:
<Window.Resources>
<converters:ResultStateToColour x:Key="ResultStateToColourConverter" />
<DataTemplate DataType="{x:Type metaClasses:CustomerProcessingResult}">
<Label Content="{Binding CustomerName}" FontWeight="Bold"
Background="{Binding ResultState,
Converter={StaticResource ResultStateToColourConverter}}" />
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="5"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="5"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="5"></RowDefinition>
</Grid.RowDefinitions>
<ListBox Grid.Column="1" Grid.Row="1" Width="150" x:Name="ListCustomerResults" >
</ListBox>
However, when I set my item source in code behind, no colours are being set on the backgrounds.
I put a break point in my converter and it is being triggered, and the correct value is being received/returned.
Why would this not be applying the colour correctly?
Thanks