Why does Transition not work? #13960
-
I asked a similar question before, but no one answered it maybe because my code was too complicated.:#13946 I have been studying this these days, and I used the simplest code to reappear this problem. Now I can restore the problem, but I am not sure whether it is a problem with my code or a bug in Avalonia. So, I have to put it up for everyone to help. XAML:
Code-behind:
As you see, every time I click the button, the border resets the TranslateTransform to 0,0 and then jumps directly to the target value without any animation at all. No matter if I change TranslateTransform to RotateTransform or ScaleTransform, the problem still exists.For example: What's wrong with it? The version of Avalonia I am using is 11.0.6. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It needs an initial transform to be set. Something like |
Beta Was this translation helpful? Give feedback.
Per this Avalonia article, How to Use Transitions, you can't transition a RenderTransform directly. Instead, you need to use TranformOperations.Parse(...).
I was able to get your original code to work by changing this one line in
B_Click
: