I have a story board where I am making a rectangle move up like a needle in a MPH car gauge. So, I make it go from 0 to 60 and I want to be able to get its current value while it’s changing so I can use that value to make a digital gauge.
How can I get the current value from the beginning to the end of a double animation? I have something like this:
DoubleAnimation da = new DoubleAnimation();
da.Duration = new Duration(TimeSpan.FromSeconds(5));
da.From = 0;
da.To = 60;
RotateTransform rt = new RotateTransform();
rt.CenterX = 35;
rt.CenterY = 0;
rec3.RenderTransform = rt;
rt.BeginAnimation(RotateTransform.AngleProperty, da);
When it rotates the rectangle up I tried to get that angle but it just returned zero.
You must be doing something wrong, consider this example:
It displays the value just fine.
If you assign the
rt.Angleto some variable that variable will have the value of the transform angle at that point in time, it will not change concurrently with thert.Angleproperty.If you are new to databinding which i used in the above code you might want to check out the overview.