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

  • Home
  • SEARCH
  • 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 158201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:38:23+00:00 2026-05-11T10:38:23+00:00

I am using a DoubleAnimation to anamiate the Angle property of a RotationTransform. Several

  • 0

I am using a DoubleAnimation to anamiate the Angle property of a RotationTransform. Several times per second, I need to change the rate of the rotation in response to external data so that the rotation speeds up and/or slows down (smoothly) over time. I am currently doing this by using a DoubleAnimation that repeats forever from 0.0 to 360.0 with duration X, then several times per second:

  • Grab a new value from external data
  • Modify the rate on the DoubleAnimation to that value
  • Re-Apply the DoubleAnimation to the Angle property again

Note: I did find that I had to change the To and From properties on the animation to ‘current angle’ and ‘current angle+360’ – lucky for me RotationTransform has no trouble with angles > 360 degrees – to prevent starting the rotation over again from zero angle.

My question is: Is this reasonable? It does not seem so. Continously applying new DoubleAnimations to the Angle property on a rotation transform seems wrong – sort of like I am letting WPF animate the rotation, while I am animating the rotation speed myself.

Is there a better way?

  • 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. 2026-05-11T10:38:23+00:00Added an answer on May 11, 2026 at 10:38 am

    On the storyboard there is a SpeedRatio setting which is a multiplier to the duration. You cannot bind to this however as it is not a dependency property.

    To get around this you can use the SetSpeedRatio function on the storyboard. Note this only works if the story board is started in code (other wise you get an error).

    The code below is an full example of how you would raise event in an object to effect the speed of the animation of a spinning rectangle. The purpose of the textbox and data bindings are to update the background object. The button is just so the textbox looses focus and updates the object.

    <Window x:Class='WpfApplication1.Window1'     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     Title='Window1' Height='300' Width='300'>     <StackPanel>       <Rectangle Margin='50' Width='50' Height='50' Fill='Red' x:Name='rc'>         <Rectangle.RenderTransform>           <RotateTransform x:Name='TransRotate'                            CenterX='25' CenterY='25' Angle='0' />         </Rectangle.RenderTransform>         <Rectangle.Resources>           <Storyboard x:Key='spin'>             <DoubleAnimation x:Name='da'                               Storyboard.TargetName='TransRotate'                               Storyboard.TargetProperty='Angle'                              By='360'                               Duration='0:0:10'                                AutoReverse='False'                               RepeatBehavior='Forever' />           </Storyboard>         </Rectangle.Resources>       </Rectangle>       <TextBox Text='{Binding Speed}' />       <Button>Update Speed</Button>     </StackPanel> </Window> 

    Then the C# code

    {     public Window1()     {         InitializeComponent();          //create new  object         BackgroundObject bo = new BackgroundObject();          //binding only needed for the text box to change speed value         this.DataContext = bo;          //Hook up event         bo.SpeedChanged += bo_SpeedChanged;          //Needed to prevent an error         Storyboard sb = (Storyboard)rc.FindResource('spin');         sb.Begin();      }      //Change Speed     public void bo_SpeedChanged(  object sender, int newSpeed)     {         Storyboard sb = (Storyboard)rc.FindResource('spin');         sb.SetSpeedRatio(newSpeed);     } }  public delegate void SpeedChangedEventHandler(object sender, int newSpeed);  public class BackgroundObject {     public BackgroundObject()     {         _speed = 10;     }      public event SpeedChangedEventHandler SpeedChanged;      private int _speed;     public int Speed     {          get { return _speed; }         set { _speed = value; SpeedChanged(this,value); }     } } 

    I am sure you can adapt to your usage.

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

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Where to use an ID versus a class The simple… May 11, 2026 at 1:17 pm
  • added an answer you can run iisapp.vbs /a 'App Pool Name' /r This… May 11, 2026 at 1:17 pm
  • added an answer You probably want something like slide: function(event, ui){ $('#current_value').text('Value is… May 11, 2026 at 1:17 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.