I have a simple ComboBox inside a MVVM app.
The important things inside the ComboBox look like this:
<ComboBox Name="EmployeesComboBox"
ItemsSource="{Binding EmployeeEntries}"
SelectedValuePath="Id"
SelectedValue="{Binding Id}"
Width="192" FontFamily="Arial" FontSize="12">
<ComboBox.Resources>
<Storyboard x:Key="BlinkingStoryboard">
<ColorAnimation Storyboard.TargetProperty="Background.Color" Duration="0:0:2"
From="White" To="Yellow" RepeatBehavior="Forever" AutoReverse="True" />
</Storyboard>
</ComboBox.Resources>
</ComboBox>
I changed even the style of the XAML of the ToggleButton(inside the ComboBox Style definitions) like follows:
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="templateRoot"
BorderBrush="{StaticResource ComboBox.Static.Border}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<Border x:Name="splitBorder"
BorderBrush="Transparent" BorderThickness="1"
HorizontalAlignment="Right" Margin="0"
SnapsToDevicePixels="true"
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Path x:Name="arrow" Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z"
Fill="{StaticResource ComboBox.Static.Glyph}"
HorizontalAlignment="Center" Margin="0"
VerticalAlignment="Center"/>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
(I took most of the definition out of the original style and only changed the Background="{StaticResource ComboBox.Static.Background}"
to the Background="{TemplateBinding Background}"
.
After that I could use the Background property inside the XAML to change the color of the ComboBox as intended, but I need to fire the StoryBoard, so that I can make the ComboBox 'blink' by programmatically means.
As soon as I start the Storyboard the app crashes (timer dont work anymore, and so on) wihtout error messages.
Anyone an idea what I am missing?