Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1013259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:04:27+00:00 2026-05-16T10:04:27+00:00

I’m restyling a button, and that includes providing a controlTemplate and also adding some

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:04:28+00:00Added an answer on May 16, 2026 at 10:04 am

    I see three issues.

    One is that you are adding the Storyboard to a resource dictionary without specifying a key. I think you want x:Key instead of x:Name.

    The next is that by setting Storyboard.Target to a binding with RelativeSource Self, you’re setting the target to the ColorAnimation itself. You can actually just leave that attribute off and it will target the Button by default.

    Finally, you have the TargetProperty set to Foreground, but you actually want to animate the Color property of the Foreground brush, so you need to use Foreground.Color. Try this:

    <Storyboard x:Key="mouseOverText">
        <ColorAnimation
            Storyboard.TargetProperty="Foreground.Color"
            From="{StaticResource ResourceKey=ForeColour}"
            To="{StaticResource ResourceKey=GlowColour}"/>
    </Storyboard>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.