Avalonia: How to animate a rotation?

Created on 25 May 2019  路  2Comments  路  Source: AvaloniaUI/Avalonia

Dears,

I have this image:
<Image Classes="Rotating" Source="/Assets/icon_gear.png" />

and I want it to start spinning right after the window is shown. So I've followed this: http://avaloniaui.net/docs/animations/keyframe

I've added this Style:
<UserControl.Styles> <Style Selector="Image.Rotating"> <Style.Animations> <Animation Duration="0:0:5"> <KeyFrame Cue="0%"> <Setter Property="**Angle???**" Value="0"/> </KeyFrame> <KeyFrame Cue="100%"> <Setter Property="**Angle???**" Value="360"/> </KeyFrame> </Animation> </Style.Animations> </Style> </UserControl.Styles>

As you see, I don't know which Property to set so that it can spin.
In "classic" XAML, one way it to use Storyboards: https://stackoverflow.com/a/12298305/901046
But I don't see them in Avalonia...

question

Most helpful comment

Try doing RotateTransform.Angle , all four built-in transforms (ScaleTransform,RotateTransform,TranslateTransform & SkewTransform) are invokable in animations. There's an sample project in the repo so do check it out for later reference.

Also we don't use any Storyboard, but we follow CSS more closely on this regard (same goes with styles).

All 2 comments

Try doing RotateTransform.Angle , all four built-in transforms (ScaleTransform,RotateTransform,TranslateTransform & SkewTransform) are invokable in animations. There's an sample project in the repo so do check it out for later reference.

Also we don't use any Storyboard, but we follow CSS more closely on this regard (same goes with styles).

Aaaaand it works! 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

khoshroomahdi picture khoshroomahdi  路  4Comments

Urgau picture Urgau  路  3Comments

Suriman picture Suriman  路  3Comments

x2bool picture x2bool  路  4Comments

CreateLab picture CreateLab  路  3Comments