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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:57:35+00:00 2026-05-27T21:57:35+00:00

I wrote a style for a button to let it rotate a bit when

  • 0

I wrote a style for a button to let it rotate a bit when the mouse is over it. Unfortunately the animation does not start.

I have a created a similar style for another button type in my application which uses the VisualStateManager as well and works perfectly well so I don’t think it is a problem with the VSM.

Seems there is a problem with the animation but I can’t find the issue.

This is what the style looks like:

<Style x:Key="MyButton" TargetType="Button">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Grid>
                    <ContentPresenter Content="{TemplateBinding Content}">
                        <ContentPresenter.RenderTransform>
                            <TransformGroup>
                                <RotateTransform CenterX="0.5" CenterY="0.5" Angle="0" x:Name="content"/>
                            </TransformGroup>
                        </ContentPresenter.RenderTransform>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="MouseOverState">
                                    <Storyboard AutoReverse="True" RepeatBehavior="Forever">
                                        <DoubleAnimation From="0"  To="10" Duration="0:0:1" 
                                                 Storyboard.TargetProperty="Angle"
                                                         Storyboard.TargetName="content"/>
                                        <DoubleAnimation From="10"  To="0" Duration="0:0:1" BeginTime="0:0:1" 
                                                 Storyboard.TargetProperty="Angle"
                                                         Storyboard.TargetName="content"/>
                                        <DoubleAnimation From="0"  To="-10" Duration="0:0:1" BeginTime="0:0:2" 
                                                 Storyboard.TargetProperty="Angle"
                                                         Storyboard.TargetName="content"/>
                                        <DoubleAnimation From="-10"  To="0" Duration="0:0:1" BeginTime="0:0:3" 
                                                 Storyboard.TargetProperty="Angle"
                                                         Storyboard.TargetName="content"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </ContentPresenter>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

I have also tried

 Storyboard.TargetProperty="(ContentPresenter.RenderTransform).(RotateTransform.Angle)"
  • 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-27T21:57:35+00:00Added an answer on May 27, 2026 at 9:57 pm

    You have a few problems with this template:

    • The VisualStateManager.VisualStateGroups elements needs to be the child of your first FrameworkElement, which in this case is a Grid
    • The VisualState “MouseOverState” should be renamed “MouseOver”
    • Each storyboard can animate each dependency property once. You have 4 double animations all attempting to animate the Angle property. What you need to use here is a DoubleAnimationUsingKeyframes that has either LinearDoubleKeyframes or EasingDoubleKeyframes.

    Here is a working version of this template:

    <Style TargetType="Button" x:Key="MyButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="MouseOver">
                                    <Storyboard AutoReverse="True" RepeatBehavior="Forever">
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Angle" Storyboard.TargetName="content">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="10"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:3" Value="-10"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:4" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter Content="{TemplateBinding Content}">
                            <ContentPresenter.RenderTransform>
                                <TransformGroup>
                                    <RotateTransform CenterX="0.5" CenterY="0.5" Angle="0" x:Name="content"/>
                                </TransformGroup>
                            </ContentPresenter.RenderTransform>
    
                        </ContentPresenter>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have button with this style: <Style TargetType=Button x:Key=btnStyle> <Setter Property=Template> <Setter.Value> <ControlTemplate TargetType=Button>
why when i write document.getElementByClass('home1').setAttribute('style', 'background-image:url(img/red_menu.PNG);'); it doesn't work? i have the element with
Basically I have a webcontrol that contains a gridview with an export button. When
I write a MFC application and need a button which is not taling the
I have a hello-world style java ee application using maven3 glassfish3 and javaee6. I
<td nowrap valign=top> <input class=formsubmit id=btnGo type=button value=Show Description style = <%# If (DataBinder.Eval(Container,
For example: <input name=abutton type=button value=This is not a button /> I know this
I have a problem changing the focus to some button on xaml. The code
I'm trying to write a program to process the BSD-style process accounting file under
In my team I've been told to write resource class like this style: class

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.