I have a Combobox With a custom ControlTemplate
and I want to change the BackgroundColor
based on the Controls Validation.Errors
property which is a WPF concept on validation.
I've decided to this by using a Trigger
. My ControlTemplate.Triggers
is defined like this
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors), Converter={StaticResource validationRequiredError}}" Value="True">
<Setter Property="Background" TargetName="Border" Value="DeepPink"/>
</DataTrigger>
</ControlTemplate.Triggers>
My Combobox looks like this:
<ComboBox Margin="0" Height="30" HorizontalAlignment="Stretch" VerticalContentAlignment="Center"
IsSynchronizedWithCurrentItem="True"
DisplayMemberPath="Description"
IsEditable="False"
Style="{StaticResource ValidateableCombobox}"
ItemsSource="{Binding Lists.EstimatedDurations}"
SelectedValue="{Binding Model.EstimatedDuration, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="Duration"/>
I've sure that the validation defined in FluentValidation
is run and added to the Errors
Collection, but the converter specified in the Trigger is never run.
I have also checked the Output to verify Binding Errors, but none are shown. Do I need to add something special to my ControlTemplate
to make sure the Errors
property are bound correctly? Can anyone point me in the correct direction?
Thanks!