P
P
postya2020-01-24 12:08:10
WPF
postya, 2020-01-24 12:08:10

How can I make the animation look the same when the program window is resized?

Application in C# + WPF
There is an animation (moving an object along the X axis)
When you click on one of the numbers on the cloaviator, the animation starts
The problem is that in the animation I set the exact coordinates of the movement, and if I make the program window smaller or larger, then the animation does not work either, the object is not shifted relative to the size of the program window.
How to make the animation look the same at different program window sizes?

DoubleAnimation animRemoveCard = new DoubleAnimation(-100, 1300, TimeSpan.FromMilliseconds(250));
TranslateTransform showCardTranslate = new TranslateTransform();
TransformGroup myTransformGroup = new TransformGroup();

myTransformGroup.Children.Add(showCardTranslate);

window.cardQuestionBorder.RenderTransform = myTransformGroup;

SineEase sineEase = new SineEase();
sineEase.EasingMode = EasingMode.EaseOut;

animRemoveCard.EasingFunction = sineEase;

showCardTranslate.BeginAnimation(TranslateTransform.XProperty, animRemoveCard);

I tried to do like this:
DoubleAnimation animRemoveCard = new DoubleAnimation(-100, SystemParameters.PrimaryScreenWidth / 1.5, TimeSpan.FromMilliseconds(250));

no effect

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question