To indicate an error, I would like to temporarily change the background color of the button. I am new to WPF animation and could not find a simple example. And to complicate matters even further, I use a trigger to handle error notifications.
So here is my XAML, and I would like to know how to replace the background setter with animation (say, blink red three times in five seconds or something like that).
<UserControl>
<UserControl.Resources>
<Style x:Key="ErrorStyle" TargetType="Button">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<AdornedElementPlaceholder />
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
<Setter Property="Background" Value="Orange"/>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid>
<Button Command="{Binding ProgramCommand, ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"
Style="{StaticResource ErrorStyle}">
_Program
</Button>
</Grid>
</UserControl>
I am also open to suggestions for a more efficient (simple) error notification.
source
share