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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:57:58+00:00 2026-05-18T08:57:58+00:00

So I have a gauge that I’ve made that will be animating in either

  • 0

So I have a gauge that I’ve made that will be animating in either the clockwise or counter-clockwise directions. Every so often new data comes in to two dependency properties that I have set up. When the data in these properties changes, I want to do some calculations on both values to determine which direction (and by how much) the gauge’s needle will rotate.

I’ve got the rotation code working, I’ve written a function (all in C#) that takes the start angle, end angle, and duration for the rotation. The rotation function works, I can put values in and watch the needle rotate.

What I can’t figure out how to do is call this animation function when either of the dependency properties changes. It wouldn’t be appropriate to make my rotation function static because the rotation calls may end up being instance specific.

In other words, what I’d like to achieve is PropertyChanged->calculate new positions/speed->build storyboard and run the animation.

My reasoning for having dependency properties instead of standard properties is because they are bound to outside of the control from xaml.

Thanks!

        private void AnimatePointer(double startAngle, double endAngle, TimeSpan length, string pointerName)
    {
        DoubleAnimation handRotation = new DoubleAnimation();
        handRotation.From = startAngle;
        handRotation.To = endAngle;
        handRotation.Duration = new Duration(length);
        Storyboard.SetTargetName(handRotation, pointerName);

        DependencyProperty[] propertyChain =
            new DependencyProperty[]
            {
                Rectangle.RenderTransformProperty,
                TransformGroup.ChildrenProperty,
                RotateTransform.AngleProperty
            };

        string anglePath = "(0).(1)[1].(2)";
        PropertyPath propPath = new PropertyPath(anglePath, propertyChain);
        Storyboard.SetTargetProperty(handRotation, propPath);

        Storyboard sb = new Storyboard();
        sb.Children.Add(handRotation);
        sb.Begin(this);
    }
  • 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-18T08:57:58+00:00Added an answer on May 18, 2026 at 8:57 am

    I was being silly and overlooked the fact that the first parameter to all of the static callback methods is the instance that the method is being called on. It simply needs to be casted to whatever your type is then the properties can be accessed through that.

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

Sidebar

Related Questions

No related questions found

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.