Animation in WPF--(c) timeline (TimeLine)

Source: Internet
Author: User

Original: Animation in WPF--(iii) timeline (TimeLine)

The time Line (TimeLine) represents the time period. It provides properties that allow you to control the length of the time period, the start time, the number of repetitions, the speed of progress in the time period, and so on. The following types of timeline are built into WPF:

    • AnimationTimeline : This is the most common animation, described earlier, primarily for the transition of attributes.
    • Mediatimeline: The timeline used to control the playback of media files.
    • Paralleltimeline:paralleltimeline is a timeline for grouping other timelines that you can use to implement more complex animations.
    • Storyboard : A special Paralleltimeline that provides object and property target information for the timeline it contains. It is often used in XAML, followed by a special introduction.
    • Timelinegroup: An abstract class that can contain Timeline objects of other Timeline objects.

Common Properties:

    • Duration: Length of animation play time
    • RepeatBehavior: Repeat behavior (number of repetitions)
    • Fillbehavior: Behavior After the end of the animation (to keep the end state of the animation or revert to its original state)
    • AutoReverse: Play the animation repeatedly in reverse order
    • SpeedRatio: Animation playback rate (for accelerated or slow playback)
    • BeginTime: Start time of animation playback

Time Line control:

So far, though, we can create and execute animations, but only through UIElement. BeginAnimation performs the start animation and cannot interactively control the animation. In WPF, you also provide a series of control actions on the timeline, such as Start, stop, pause, and so on. They are performed by the Controller property of the clock object. Here's a simple example:

VarWidthanimation =new doubleanimation ()
    {
        from = 0,
         to = +,
        duration = timespan     };

    var Clock = Widthanimation.createclock ();
    button. ApplyAnimationClock (widthproperty, clock);

    awaittask     clock. Controller.pause ();

As you can see from this code, the general steps to control the timeline are as follows:

    1. Clock object creation by Createclock function
    2. Through UIElement. The ApplyAnimationClock function enables animation that supports clock control
    3. Use clock. Controller's method control animation

A more detailed example can be see the MSDN documentation: interactively control the clock

In addition to providing an interactive method in the controller, the clock object also provides a series of properties and events to facilitate our access to the state, common are:

    • Currentprogress Current Progress
    • CurrentState Current status
    • CurrentTime Current Playback time
    • Whether the ispaused is in a paused state
    • Naturalduration Animation duration

A series of events are also provided to proactively notify the state of changes, and commonly used events are:

    • Completed: Notification at the end of the animation
    • currentglobalspeedinvalidated notification when the playback rate changes,
    • Notification of currentstateinvalidated status changes
    • CurrentTimeInvalidated notification when the playback time changes
    • Removerequested notification when animation is removed

These events are also available in the Timeline object, so that you can change the state without using the clock object. If you want more revenue to understand how the timekeeping system works, you can look at the animation and timing System overview article.

In addition, some special timeline objects, such as the storyboard itself, encapsulate the control-related content of the animation and can control the animation directly. About storyboard need to introduce more content, and then write a separate article introduction.

Resources:

    • Overview of timing behavior
    • Overview of Timing Events
    • Timeline class
    • Clock class
    • Synchronous positioning clock

Animation in WPF--(c) timeline (TimeLine)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.