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 6336471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:03:47+00:00 2026-05-24T19:03:47+00:00

I have the following code: <Style x:Key=GoButton TargetType=Button> <Setter Property=Background Value=#FF2B832C/> <Setter Property=Foreground Value=#FFfdf7bd/>

  • 0

I have the following code:

<Style x:Key="GoButton" TargetType="Button">
    <Setter Property="Background" Value="#FF2B832C"/>
    <Setter Property="Foreground" Value="#FFfdf7bd"/>
    <Setter Property="FontSize" Value="30" />
    <Setter Property="Padding" Value="3"/>
    <Setter Property="BorderThickness" Value="3"/>
    <Setter Property="BorderBrush">
        <Setter.Value>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="#4d9e41" Offset="0" />
                <GradientStop Color="#294c22" Offset="1" />
            </LinearGradientBrush>
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal">
                            </VisualState>
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <DoubleAnimation Duration="0:0:1" Storyboard.TargetProperty="FontSize" To="35" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="FocusStates">
                            <VisualState x:Name="Focused">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Unfocused"/>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Border x:Name="Background" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="5">
                        <Grid Background="{TemplateBinding Background}" Margin="0">
                            <Border x:Name="BackgroundAnimation" Background="#FF448DCA" CornerRadius="5" Opacity="0"/>
                            <Rectangle x:Name="BackgroundGradient" RadiusX="5" RadiusY="5">
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint="0.8,1" StartPoint="0,0">
                                        <GradientStop Color="#66b04d" Offset="0"/>
                                        <GradientStop Color="#66b04d" Offset="0.375"/>
                                        <GradientStop Color="#2d822d" Offset="0.625"/>
                                        <GradientStop Color="#2d822d" Offset="1"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                        </Grid>
                    </Border>
                    <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    <Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" IsHitTestVisible="false" Opacity="0" RadiusY="6" RadiusX="6"/>
                    <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Margin="1" Opacity="0" RadiusY="5" RadiusX="5" Stroke="#FF6DBDD1" StrokeThickness="1"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

I want to change FontSize when user MouseOver on button. But this code does not work, it works if I remove string, but without my animation:

<DoubleAnimation Duration="0:0:1" Storyboard.TargetProperty="FontSize" To="35" />

how to do it correctly?

  • 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-24T19:03:50+00:00Added an answer on May 24, 2026 at 7:03 pm

    I got your animation to work by replacing the <ContentPresenter> in your template with

    <ContentControl x:Name="nestedContentControl" ContentTemplate="{TemplateBinding ContentTemplate}" 
                    Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}"
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
    

    and then setting Storyboard.TargetName of your MouseOver animation to nestedContentControl.

    The problem appears to be providing a value for Storyboard.TargetName. Although you can access the name of the control the template applies to (i.e. the Button that uses this template), the Storyboard doesn’t seem able to access the templated control. So instead we nest another ContentControl (Button is itself a ContentControl) within the template and use that.

    Using another ContentControl has its downsides, however. I had to add the Foreground="{TemplateBinding Foreground}" property in order for it to pick up the foreground colour you were using. It’s quite possible that you might need to add further such ‘pass-through’ bindings depending on what other properties you need to use.

    Be aware that there is also an animation on your Focused VisualState. This animation won’t work as it stands because you haven’t specified a TargetName for it. I don’t know what to suggest for this one because I’m not sure what you’re trying to achieve.

    Finally, while answering this question I also found a similar question about animating a property of the templated-parent object. In that case, the solution appears to be to wire up the animation in code-behind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following simple code, but it doesn,t work <ul> <li id=one onmouseover=this.style.background-color='white';>
I have the following code: <HTML> <head> <style>div{border:dashed 1px silver}</style> </head> <BODY style=background: #fff;>
I have the following code <HTML> <HEAD> <style type=text/css> .setbgcolor{ background-color:blue; } </style> <script
I have the following code <html> <head> <title>Test</title> <style type=text/css> <!-- body,td,th { color:
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
I have the following code that applies a XSLT style Test.Xml.xslTransform = function(xml, xsl)
I have the following code: <asp:Content ID=StyleContent ContentPlaceHolderID=StyleContent runat=server> <style type=text/css> #mask { position:absolute;
The Problem I have the following code: <html> <head> <style id=ID_Style> .myStyle { color
I have written following code which generates a browse and upload button.i want to
I have the following code in my activity: ...... DataCell[i] = new TextView(context,null,R.style.TitleRow); DataCell[i].setText(data[i]);

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.