Skip to content
Discussion options

You must be logged in to vote

This is what I did (because I have my own templated control:

  • Extended styled properties with a TimeSpan PressedAnimationStateDuration
  • Added a DispatcherTimer
  • If above duration is > TimeSpan.Zero the code behind adds a custom PseudoClass and starts the timer. The first timer tick will remove the pseudo class and stop the timer
  • I can then define the animation in Xaml as I want. I just need to make sure that the PressedAnimationStateDuration is sufficient for the Xaml animation

Code Behind:

public static readonly StyledProperty<TimeSpan> PressedAnimationStateDurationProperty =
    AvaloniaProperty.Register<MenuActionItem, TimeSpan>(nameof(PressedAnimationStateDurationProperty), TimeSpan.Zero)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by llfab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant