Answer the question
In order to leave comments, you need to log in
How to play StoryBoard animation on Tapped event?
There is a UWP application, it navigates through pages displaying various content.
In a separate xaml file, I drew an animation of clicking on the screen (like in this picture, only without a hand).
How can I play this animation when I click on any area in the application? In essence, this is feedback on touch.
There is a crutch, outside the screen area, place the ellipses drawn by me and place the storyboard in the page resources, after which, with the tapped event, transfer this object to the pointer position and start the animation. But I don’t want to do this, in view of the fact that it will not be possible to play several instances of this animation (again, without crutches). Plus, you will have to fence this crutch on each of the pages.
Answer the question
In order to leave comments, you need to log in
The solution is:
app_namespace - the namespace of the application
Media - the directory where the asset is located
Circles - the name of the xaml file
circle - the name of the class
app_namespace.Media.circles circle = new app_namespace.Media.circles();
circle.Width = 400;
circle.Height = 400;
circle.HorizontalAlignment = HorizontalAlignment.Left;
circle.VerticalAlignment = VerticalAlignment.Top;
circle.Margin = new Thickness(pointerPosition.X - 200, pointerPosition.Y - 200, 0, 0);
Canvas.SetZIndex(circle, 2);
maingrid.Children.Add(circle);
Storyboard sb = circle.Resources["anim_pulse"] as Storyboard;
sb.Begin();
sb.Completed += (s, h) => maingrid.Children.Remove(circle);
maingrid.Children.Add(circle);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question