"Programming WPF" translation 8th Chapter 3.Storyboard

Source: Internet
Author: User
Tags xmlns

Storyboard is a collection of animations. If you use a tag, all animations must be defined in a storyboard. (It is possible to create an isolated animated object in your code, see later in this chapter.) The structure of an animation is usually different from the structure of the animated UI. For example, you might want to come up to two individual user interface elements at the same time to be animated. Because storyboard separates animations from animated objects, storyboard is free to reflect such connections, even if they are set to objects, and may be defined in completely different parts of the file.

Example 8-15 shows the markup for the user interface that contains two ellipses.

Example 8-15

<window text= "Two animations width=" 420 "height=" "
xmlns=" http://schemas.microsoft.com/winfx/ avalon/2005 "
xmlns:x=" http://schemas.microsoft.com/winfx/xaml/2005 "

<window.storyboards> <paralleltimeline>
<settertimeline targetname= "Myellipse" path= "(ellipse.width)" > <doubleanimation from= "Ten" to= "duration=" "0:0:5"
Repeatbeha Vior= "Forever"/>
</settertimeline>
<settertimeline targetname= "Myotherellipse                                  "Path=" (ellipse.width) "
<doubleanimation from=", "to=" and "The Duration="
Repeatbehavior= "Forever"/>
</settertimeline>
</paralleltimeli Ne>
</window.storyboards>

<stackpanel orientation= "Horizontal"
<ellips E x:name= "Myellipse" height= "1"Fill=" Red "/>
<textblock>this is some text</textblock>
<ellipse x:name=" Myot Herellipse "height=" fill= "Blue"/>
</stackpanel>
</window>

These ellipses are not contiguous, but their widths are animated in an asynchronous fashion. This asynchronous reflection is reflected in the storyboard structure: These two animations are embedded in the same Paralleltimeline element, indicating that the animations are running at the same time. One animation from 10 to 300 and the other from 300 to 10, so the total width of the three items in the StackPanel remains constant.

Storyboard must be run in one of three different locations. They can be placed in style, in ContentTemplate, or in top-level elements. The top-level elements are window and page, or the class that is derived from this.

All user interface elements have a storyboard attribute that inherits the base type FrameworkElement. You might want to mean that you can add a storyboard to any element. This is not supported at the moment. Storyboard works only in: style, in ContentTemplate, or in top-level elements.

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.