Skip to content

Why does Transition not work? #13960

Answered by andrewkdci
kyuranger asked this question in Q&A
Dec 15, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

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:

    private void B_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Random R = new Random(DateTime.Now.Millisecond);
        border.RenderTransform = TransformOperations.Parse($"translateY({R.Next(100, 500)}px)");
    }

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kyuranger
Comment options

@andrewkdci
Comment options

Answer selected by kyuranger
@kyuranger
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants