Nibblestutotials.net tutorial-States-Part2 in the blend & silverlight2 Series

Source: Internet
Author: User

Part 2: Transformation and keyspline

This section will teach you some advanced blend 2 SP1 technologies: How to Create transformations and perform more control.

To complete this step, you need to install expression blend 2 SP1 or later.

TheCodeDownload from here

    1. Download and open the project

Use the link above to download the project and open it.

You should see something as shown in.

 

    1. Create a new over status

Use the same method in the previous tutorialMouseinteractionCreate a new name in the groupOver.

    1. ClickAdd statusCreate a new state.
    2. Rename itOver.

 

    1. Change the over status attribute

For the over status, reduce the image size.

    1. Select the over status, click the image, and change scale transform to X = 0.55, y = 0.55.

 

    1. Add mouse entry and remove events

    1. Click the image to select it. The event bar under the Property panel is displayed.
    2. In the mouseenter and mouseleave events, enter goover and goleave respectively. (See figure)

This will create two functions in page. XAML. CS to become goover and goleave respectively.

 

    1. Add code to page. XAML. CS

To make the status work, you need to add the following code in the goover function, just as we did in the previous tutorial.

Visualstatemanager. gotostate (this, "over", true );

Add the code to the goleave function to return the normal state.

Visualstatusmanager. gotostate (this, "normal", true );

See images.

 

    1. Control Transformation

If you runProgram, You will see that all the statuses can work, from normal to over, to click, return over, return normal, and so on. However, all the transformations take place in 0.3 seconds. This is the default value defined for the status group.

To control a single transformation, we need to add...Transform. Let's addOverToClick.

    1. InOverClick on statusAdd Transform.

It shows you a list of all possible combinations of changes in the group.

    1. SelectOver-> click. Next new transformation over.
    2. Change the time0.1.

If you run the program, you will see that when you click, the animation speed will become much faster. This is a powerful feature because it allows you to control any State to make it another state.

(*) Symbol allows you to define a transform to make all (*)ChangeA specified status.

 

    1. Each status has a timeline

When we use the stateDurationWhen the option defines the time of each transformation, we do not have the option to defineKeyspline(How to accelerate an animation ). To control the keyspline, we need to open the timeline of the status.

    1. SetDefault conversion Interval0.
    2. ClickDelete changesTo removeOver-> clickTransform.
    3. SelectOverStatus
    4. ClickShow timelineTo extend the over status timeline

You will seeImageThere is only one elementKeyframe. Now you can create an animation, just like any otherStoryboard.

 

    1. Change transform using timeline

Now that you have accessed the timeline, you can control the animation time here.

    1. To changeTime, DragKeyframeTo the target location. In the example image, the example is a one-second transformation. But a better result would be:0.3 s.

 

    1. Modify keyspline

Another advanced application of timeline is that you can changeKeysplineAnd control the slow in/out of each key frame.

    1. ClickKeyframeAnd changeAttributePanelKeysplineGraph

In this example, we get a more natural animation, instead of a boring start/end.

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.