-
Hi, I am probably not looking at the correct place, or have misunderstood the requirements, but I cannot find an example how on how to combine the Is this possible currently? I apologise for my lack of knowledge, first time I'm using Avalonia. I want to add animations to my views, preferably without using a style if possible. Thanks for any help! So far I am loving this project. :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@Zolomon I see you closed the discussion already. There is an example of manually starting animations in the |
Beta Was this translation helpful? Give feedback.
-
Thanks! After a couple of hours late this early morning I managed to figure out how to achieve what I wanted: // Example modified from the Examples/TodoApp
Button.styles (
let styles = Styles()
let style = Style(fun x -> x.OfType<Button>().Template().OfType<ContentPresenter>())
let setter = Setter(ContentPresenter.CornerRadiusProperty, CornerRadius(10.0))
style.Setters.Add setter
let animation = Animation()
.WithDuration(1.0)
.WithEasing(CubicEaseIn())
.WithFillMode(FillMode.Forward)
.WithKeyFrames [
KeyFrame()
.WithCue(0)
.WithSetter(Component.OpacityProperty, 0.0)
KeyFrame()
.WithCue(1)
.WithSetter(Component.OpacityProperty, 1.0)
]
animation.IterationCount <- IterationCount(2UL, IterationType.Many)
style.Animations.Add ( animation )
styles.Add style
styles
) Think I should be able to create some helper functions to reduce the verbosity. |
Beta Was this translation helpful? Give feedback.
Thanks! After a couple of hours late this early morning I managed to figure out how to achieve what I wanted: