Yesterday, we penned on how to monetize your applications through marketing. I’m going to show you how to add some movement and flair to your application by using animations today.
That Awesome Door Open Animation
You get this really nice “door open” animation that happens before your application loads if you’ve ever opened an application in the emulator. I’m going to exhibit you the way to include that style of animation to your pages. (It’s really surprisingly easy. )
Grab yourself a project that is new the Windows Phone Application template if you’d like to follow along), and add a phone number for paydayloanmaryland.com rectangle towards the Grid known as ContentPanel. Here’s exactly just what mine appears like:
For producing the animation, we’re planning to do the sleep of the work with Expression Blend 4. To start any project in Blend, right click upon it in artistic Studio 2010, and choose the “Open in Expression Blend” option.
As soon as you’ve gotten assembling your shed open in Expression Blend, get the “Objects and Timeline” tab. There was a“+ that is little sign with this tab, also it’s for creating brand brand new animations, or “storyboards”.
Once you click that “+” symbol, you’ll get a dialog that appears like this. Provide your animation a title:
You’ll have returned to your things and Timeline tab, the good news is there’s a timeline that is actual the proper of one’s web web page objects. To begin to see the schedule better, press the F6 key in your keyboard. It will probably re-arrange the tabs in Expression, going the things and Timeline tab towards the whole base associated with the application.
For our “DoorOpen” animation, we’re likely to be manipulating every one of the content on our page. Fortunately, because of the hierarchical nature of Silverlight, we should just target the element that is layoutRoot. Click on LayoutRoot within the things and Timeline tab, to see an icon that is egg-shaped the Zero moments line.
That symbol shows a Keyframe. Keyframes are the ones times that are pivotal your animation whenever something changes. Silverlight is sensible sufficient to manage to figure the rest out for the animation for you personally. Therefore, within our instance, we’re planning to determine the ending and beginning of our animation, and Silverlight will need proper care of the remainder. Click on the Keyframe switch when you yourself haven’t currently.
The main reason we develop a Keyframe at Zero moments is really because we wish set up a baseline. We’re fundamentally saying our element happens to be in the “starting” position, therefore we would like you to record that data. We now have an added thing we must improvement in our” that is“starting position and that’s exactly what the rotational center of our item should really be. By standard, the middle of rotation may be the center associated with the item, but we wish our animation to fundamentally turn through the edge that is left of display screen.
Ensuring that LayoutRoot is chosen, and therefore there is certainly a“egg that is little symbol on Zero moments, have a look at the characteristics tab. Inside the “Transform” category, there is certainly another tab labeled Center of Rotation (it’s under the Projection area). You ought to observe that the X and Y values are both set to 0.5 ( the center of the element. ) We should alter our X value to 0, or perhaps the edge that is left of element.
Then, head returning to Object and Timeline. Go the line that is yellow indicates time about halfway involving the 0 and 1. While you move it, you’ll begin to see the time change next into the Keyframe button.
This time around, we’re planning to change the Projection. Rotation home. Start that area of the qualities tab up (it had been simply to the left for the Center of Rotation), and alter the Y value to 90. This can have our content rotate 90 levels to the left in a 3d rotation.
You should be able to see this animation happening now if you hit the “Play” button above the timeline. But we continue to have yet another action to just just take before this animation will happen inside our application. We must phone it from code. If you’d want to see the XAML that individuals have actually produced by using all the above actions, right here it really is (I’ve included my entire MainPage. Xaml to enable you to see most of the customizations):
Calling Animations From Code. Once we’ve created our animation, we are able to conserve every thing, and near Expression Blend.
Get back to Studio that is visual 2010 and start the code-behind file: MainPage. Xaml. Cs. We’re going to introduce our animation an individual clicks on our rectangle (the main one we added at the start, keep in mind? )
Our step that is first is produce a meeting handler when it comes to simply simply click for the rectangle, and also the 2nd is always to execute the Begin() method on our storyboard. Here’s just just what my MainPage. Xaml. Cs file seems like now:
In order that’s it! Go ahead and make use of this animation in your applications, to make sure you see all over the operating system that you can have that same “open door” animation.
Down load the Code
This test rule includes most of the rule shown above in a working project that is full. Please down load it and go on it apart, to enable you to begin animations that are using the job.