WPF StoryBoard Last Complete

HoneyBee 186 Reputation points
2022-04-01T08:00:03.177+00:00

a project that slides images.

I got help by referring to various references.

There is one problem.

If you keydown
The page slides.

At this time, the X value is adjusted using animation.

but if you hold down the key
A problem arises.

The page slides repeatedly, but
I can't find the last executed animation.

The StoryBoard's Complete event doesn't help me either.

In an animation that loops while a key is pressed
Finally, I want to fire an event when the last animation completes.

What should I do?

public void RunSlideAnimation(double toValue, double fromValue = 0)  
        {  
            if (!(this.PART_Root.RenderTransform is TranslateTransform))  
            {  
                this.PART_Root.RenderTransform = new TranslateTransform();  
            }  
  
            var story = AnimationFactory.Instance.GetAnimation(this.PART_Root, toValue, fromValue);  
            if(story.Children.Count > 1)  
            {  
                //story.SkipToFill(this);  
                //story.Children.Remove(story.Children[story.Children.Count - 1]);  
            }  
            story.Completed += (s, e) =>  
            {  
                this.RefreshViewPort(this.SelectedIndex);  
                //Debug.WriteLine("Finish");  
                if (OnPageSlideCompleted != null)  
                {  
                    OnPageSlideCompleted(null, null);  
                }  
            };  
                  
            story.Begin();  
        }  

189030-image.png

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,678 questions
{count} votes