Its very easy to implement the neat page transition effects to your Windows Phone 7 application. You have to follow some simple steps and you will get the wonderfull page transition effects. Before starting the implementation we will see some concepts.
Transition Element :-
Transition element is an abstract class that have the GetTransition(UIElement element) abstract method.By which it creates new ITransition for the given UIElement.You will find the five built in Transition Elements as follows.
- RotateTransition
- SlideTransition
- SwivelTransition
- TurnstileTransition
- Roll Transition is different from the others because it does not provide any Modeproperty.
ITransition :-
ITransition interface is the main part of the transition framework. It provides the api for all types of the custom animations. By which you can create your own animation as you want. Following are the methods which are provided by the ITransition for creating animation effects.
- Begin() – Initiates the set of animations associated with the ITransition.
- GetCurrentState() – Gets the ClockState of the ITransition.
- GetCurrentTime() – Gets the current time of the ITransition.
- Pause() – Pauses the animation clock associated with the ITransition.
- Resume() – Resumes the animation clock, or run-time state, associated with the ITransition.
- Seek() -Moves the ITransition to the specified animation position. The ITransition performs the requested seek when the next clock tick occurs.
- SeekAlignedToLastTick() – Moves the ITransition to the specified animation position immediately (synchronously).
- SkipToFill() – Advances the current time of the ITransition’s clock to the end of its active period.
- Stop() – Stops the ITransition.
Simple steps to implement Transition Effect to the application page.
- First you should install the Silverlight Toolkit for Windows Phone. You will find the dll at C:Program Files (x86)Microsoft SDKsWindows Phonev7.0ToolkitNov10BinMicrosoft.Phone.Controls.Toolkit.dll
- Just add the reference Microsoft.Phone.Controls.Toolkit.dll
- First you should not forget to add RootFrame is of type TransitionFrame in app.xaml.cs file under the method InitializePhoneApplication()
//RootFrame = new PhoneApplicationFrame(); RootFrame = newTransitionFrame();
- In each XAML page you need to add xmlns to dll,
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls; assembly=Microsoft.Phone.Controls.Toolkit"
Under the <phone:PhoneApplicationPage> root and you need to add the following XAML code at end of your code.
- For Turnstile Transition the XAML code will be look like follows :
&amp;amp;amp;amp;amp;amp;amp;lt;toolkit:TransitionService.NavigationInTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationInTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationInTransition.Backward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:TurnstileTransition Mode="BackwardIn"/&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationInTransition.Backward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationInTransition.Forward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:TurnstileTransition Mode="ForwardIn"/&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationInTransition.Forward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationInTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:TransitionService.NavigationInTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:TransitionService.NavigationOutTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationOutTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationOutTransition.Backward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:TurnstileTransition Mode="BackwardOut"/&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationOutTransition.Backward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationOutTransition.Forward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:TurnstileTransition Mode="ForwardOut"/&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationOutTransition.Forward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationOutTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:TransitionService.NavigationOutTransition&amp;amp;amp;amp;amp;amp;amp;gt;
- For Slide Transition the XAML code will be look like follows :
&amp;amp;amp;amp;amp;amp;amp;lt;toolkit:TransitionService.NavigationInTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationInTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationInTransition.Backward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:SlideTransition Mode="SlideRightFadeIn"/&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationInTransition.Backward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationInTransition.Forward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:SlideTransition Mode="SlideLeftFadeIn"/&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationInTransition.Forward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationInTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:TransitionService.NavigationInTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:TransitionService.NavigationOutTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationOutTransition&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationOutTransition.Backward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:SlideTransition Mode="SlideRightFadeOut"/&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationOutTransition.Backward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:NavigationOutTransition.Forward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;toolkit:SlideTransition Mode="SlideLeftFadeOut"/&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationOutTransition.Forward&amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;lt;/toolkit:NavigationOutTransition&amp;amp;amp;amp;amp;amp;amp;gt;
- Thats all you are done with your page transition effect. Like this you can use the another transition modes also ie. RotateTransition, SwivelTransition, RollTransition.
Download the Sample Project: Page Transition Effects in Windows Phone 7