I'm restyling a button, and that includes providing a controlTemplate and also adding some triggers (for mouseenter and mouseleave).
My XAML is as follows:
<Style TargetType="Button">
<Style.Resources>
<Color x:Key="ForeColour" R="128" G="128" B="128" A="255"/>
<Color x:Key="BackColour" R="211" G="211" B="211" A="255"/>
<Color x:Key="GlowColour" R="30" G="144" B="255" A="255"/>
<SolidColorBrush Color="{StaticResource ResourceKey=ForeColour}" x:Key="ForeBrush"/>
<LinearGradientBrush x:Key="BackBrush" StartPoint="0,1" EndPoint="0,0">
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="{StaticResource ResourceKey=BackColour}" Offset="1"/>
</LinearGradientBrush>
<Storyboard x:Name="mouseOverText">
<ColorAnimation Storyboard.Target="{Binding RelativeSource= {RelativeSource Self}" Storyboard.TargetProperty="Foreground" From="{StaticResource ResourceKey=ForeColour}" To="{StaticResource ResourceKey=GlowColour}"/>
</Storyboard>
</Style.Resources>
<Setter Property="Foreground" Value="{StaticResource ResourceKey=ForeBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border BorderBrush="LightGray" BorderThickness="2" CornerRadius="8" Background="{StaticResource ResourceKey=BackBrush}">
<ContentPresenter x:Name="cnpContent" Opacity="1" VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard Storyboard="{StaticResource mouseOverText}"/>
</EventTrigger>
</Style.Triggers>
</Style>
but when I run it I get the following error on startup:
'Missing key value on 'Storyboard' object.' Line number '88' and line position '31'.
Which corresponds to this line:
<ColorAnimation Storyboard.Target="{Binding RelativeSource= {RelativeSource Self}" Storyboard.TargetProperty="Foreground" From="{StaticResource ResourceKey=ForeColour}" To="{StaticResource ResourceKey=GlowColour}"/>
All I'm trying to do is get the button's foreground to fade to a different colour when the mouse hovers over it. Anybody have any idea where I'm going wrong? I can't seem to fathom it.