original: http://www.visuallylocated.com/post/2014/06/24/Page-transitions-and-animations-in-Windows-Phone-Runtime.aspx

With the release of Windows Phone 8.1 Runtime (aka XAML) comes a lot of functionality that previously only existed in the Windows Phone Toolkit or other third party control suites. One of these are page transitions and animations on objects. In Windows Phone 8 apps your best option for page transitions was the Windows Phone Toolkit or Telerik. I’ve used both, but really enjoy the robustness and ease of use of Teleriks transitions. With Teleriks RadTransitionControl you could setup forward and backward animations with three lines of XAML! Contrast that with the Windows Phone Toolkit where it takes 20 lines of XAML!! Because I like Teleriks transitions this post will cover moving from the Windows Phone Toolkit or the Teleriks transitions to the new transitions in the Windows Phone Runtime.

In both the Windows Phone Toolkit and Telerik you had to set the RootFrame of the App to be the control suite transition frame.

// Default

RootFrame = new PhoneApplicationFrame();

 

// WP Toolkit

RootFrame = new TransitionFrame();

 

// Telerik

RootFrame = new RadPhoneApplicationFrame();

With Windows Phone Runtime apps you do not need to do anything. When you create a new phone project, everything will be setup so that every page will show a turnstile transition! The transitions are setup within the RootFrame_FirstNavigated method,

rootFrame.ContentTransitions = this.transitions ?? new TransitionCollection() { new NavigationThemeTransition() };

Note: It is important to set the ContentTransitions of the frame. If this is null your app can crash while trying to navigate.

This sets up your app to show the NavigationThemeTransition. This is a “generic” transition that can be used all by itself. With this one line of code, every page you navigate to will use a turnstile transition!

The NavigationThemeTransition has a property, DefaultNavigationTransitionInfo, that specifies what transition to use for the page. There are three default classes that can be used, CommonNavigationTransitionInfo, SlideNavigationTransitionInfo. and ContinuumNavigationTransitionInfo. Setting up a page to use one of these is pretty simple.

<Page.Transitions>

    <TransitionCollection>

        <NavigationThemeTransition>

            <NavigationThemeTransition.DefaultNavigationTransitionInfo>

                <SlideNavigationTransitionInfo/>

            </NavigationThemeTransition.DefaultNavigationTransitionInfo>

        </NavigationThemeTransition>

    </TransitionCollection>

</Page.Transitions>

I’m not going to show how the WPToolkit or Telerik equivalent for the transitions as it would be too much.

The CommonNavigationTransitionInfo is the default NavigationTransitionInfo. It states that the page will use the turnstile transition. The CommonNavigationTransitionInfo also allows you to specify that a feather (aka stagger) page transitionshould be used. SlideNavigationTransitionInfo states that the page will use a slide transition that will animate from bottom to top when navigating in and top to bottom when navigating out. Finally, the ContinuumNavigationTransitionInfo allows you to show a “Fly away” transition like when tapping an email in the mail app. I’ll go into this in another post as well.

Along with the NavigationThemeTransition, there are other transitions that can be used for pages. The PaneThemeTransition and EdgeUIThemeTransition provide exactly the same functionality. They both allow you to use a slide transition, but to specify which edge to slide the content in from, and out to.

<TransitionCollection>

    <PaneThemeTransition Edge="Bottom" />

</TransitionCollection>

The EntranceThemeTransition is pretty cool because it allows you specify the horizontal and vertical offset that the page should navigate from. This means you can slide your page in diagonally.

<TransitionCollection>

    <EntranceThemeTransition FromVerticalOffset="200" FromHorizontalOffset="200" />

</TransitionCollection>

Those are the basic page transitions for pages. One really awesome thing that you can do with the new transitions is create what I call partial and complex transitions. This technique requires that you do not set a default transition to the root frames ContentTransitions like is done by default. You still need to create a new TransitionCollection, but do not put anything in it! With a partial or complex transition, you will [most likely] not set a transition for the page. Instead you will place transitions on the ChildrenTransitions of individual panels. The example below uses the EdgeUIThemeTransition is a sample of what I call a “complex transition”. It  slides items in from alternating sides.

<StackPanel Margin="0,0,0,9.5">

    <StackPanel.ChildrenTransitions>

        <TransitionCollection>

            <EdgeUIThemeTransition Edge="Right"/>

        </TransitionCollection>

    </StackPanel.ChildrenTransitions>

    <TextBlock Text="Item One" Style="{ThemeResource BodyTextBlockStyle}"/>

</StackPanel>

<StackPanel Margin="0,0,0,9.5">

    <StackPanel.ChildrenTransitions>

        <TransitionCollection>

            <EdgeUIThemeTransition Edge="Left"/>

        </TransitionCollection>

    </StackPanel.ChildrenTransitions>

    <TextBlock Text="Item Two" Style="{ThemeResource BodyTextBlockStyle}"/>

</StackPanel>

<StackPanel Margin="0,0,0,9.5">

    <StackPanel.ChildrenTransitions>

        <TransitionCollection>

            <EdgeUIThemeTransition Edge="Right"/>

        </TransitionCollection>

    </StackPanel.ChildrenTransitions>

    <TextBlock Text="Item Three" Style="{ThemeResource BodyTextBlockStyle}"/>

</StackPanel>

Aside from page transitions, there are some awesome animations that can be used on items. One exciting animation is tilt. Tilt is enabled on all “clickable” items by default (eg: Button, ListViewItem)! This is exciting because previously you had to set this yourself. There are a few ways to enable tilt on non-clickable items, read this post to find out more. Another awesome animation is the slide in animation that you get when changing PivotItems within a Pivot. This is a staggered slide that you get for each line of an item. Enabling this requires setting the SlideInAnimationGroup on each element you want to stagger sliding.

<DataTemplate>

    <StackPanel Margin="0,0,0,9.5">

        <TextBlock Pivot.SlideInAnimationGroup="1"

                   Text="{Binding Title}"

                   Style="{ThemeResource ListViewItemTextBlockStyle}"

                   Margin="0,0,19,0"/>

        <TextBlock Pivot.SlideInAnimationGroup="2" 

                   Text="{Binding Description}"

                   TextWrapping="WrapWholeWords"

                   Style="{ThemeResource ListViewItemContentTextBlockStyle}"

                   Margin="0,0,19,0"/>

    </StackPanel>

</DataTemplate>

I have noticed a weird bug with this animation in which items do not slide in when first changing pivot items. Keep this in mind when testing.

Another handy animation is the AddDeleteThemeTransition. With this transition, when an item is added it will open a space and be inserted into that space. When an item is removed, the item will go away and then the content will slide up in its place. This transition is already enabled on the ListView and GridView.

<ItemsControl ItemsSource="{Binding Items}" 

              ItemTemplate="{StaticResource ItemsTemplate}">

    <ItemsControl.ItemContainerTransitions>

        <TransitionCollection>

            <AddDeleteThemeTransition/>

        </TransitionCollection>

    </ItemsControl.ItemContainerTransitions>

</ItemsControl>

 
 

Windows Phone 8.1 Page transitions的更多相关文章

  1. 背水一战 Windows 10 (42) - 控件(导航类): Frame 动画

    [源码下载] 背水一战 Windows 10 (42) - 控件(导航类): Frame 动画 作者:webabcd 介绍背水一战 Windows 10 之 控件(导航类) Frame 动画 示例An ...

  2. 30+ Excellent Windows Phone 7 Development Tutorials

    原文发布时间为:2012-01-16 -- 来源于本人的百度文章 [由搬家工具导入] Here are 30+ cool Windows Phone Development articles for ...

  3. MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems

          早晨宁波那边的IT人员打电话告知数据库无法访问了.其实我在早晨也发现Ignite监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...

  4. [WP8.1UI控件编程]Windows Phone XAML页面的编译

    1.1.2 XAML页面的编译 Windows Phone的应用程序项目会通过Visual Studio完成XAML页面的编译,在程序运行时会通过直接链接操作加载和解析XAML,将XAML和过程式代码 ...

  5. WebKit内核分析之Page

    参考地址:http://blog.csdn.net/dlmu2001/article/details/6213377 注:本系列博客是在原博主博客基础上增加了自己的理解和片段,可以看源博文获得清晰的结 ...

  6. Configuring a Windows Azure Project

    A Windows Azure project includes two configuration files: ServiceDefinition.csdef and ServiceConfigu ...

  7. wp8.1 Study8:页面过渡和主题动画(Page transition and Theme animations)

    一.在WP8.1中是有动画(Animation)的: 页面导航(默认为旋转式Turnstile).PointerDown/up(默认是倾斜).页面旋转.MenuFlyout出现等等 二.页面过渡(Pa ...

  8. Windows Phone 8仿Toast弹出通知。

    Wp8后台收到消息可以弹出Toast通知,可是应用在前台跑的时候却好像没有办法弹出Toast通知.而需求上有要求要弹出Toast通知,在这种情况下,就开始考虑是否能够做一个类似Toast的弹出通知呢? ...

  9. Windows Phone中的几种集合控件

    前言 Windows Phone开发过程中不可避免的就是和集合数据打交道,如果之前做过WP App的开发的话,相信你已经看过了各种集合控件的使用.扩展和自定义.这些个内容在这篇博客里都没有,那么我们今 ...

随机推荐

  1. OTA(空中下载技术)

    选自:http://baike.baidu.com/link?url=bKOx4Gcgefi17Zt09pRA6zI-p7zzKVkoN07khRVTPfUtqyRMzdG5xURfpnp3wSP_A ...

  2. easyui datagrid导出excel

    [第十四篇]easyui datagrid导出excel   <a class="btn btn-app" onclick="exportExcel()" ...

  3. cisco LAN

    由于实验需要,需要搞个内部局域网(以前我们实验室是直接从学校拖了根线过来,然后直接用switch连).因此得先配个router,做个小局域网.由于从没接触过路由器,所以先去网上找了些资料,接着就打开c ...

  4. 设置ASP.NET MVC站点默认页为html页

    问题由来 部署了一个Asp.Net MVC的站点,其功能只是作为移动端的服务器,服务器空间里面除了CMS以外就没有其他的页面了.这对于我们来说确实是有点浪费了. 可以放点静态的啥小东西放在上面玩一玩. ...

  5. bzoj 1934: [Shoi2007]Vote 善意的投票

    #include<cstdio> #include<iostream> #define M 100000 #include<cstring> using names ...

  6. 在Tomcat下配置Solr 4.x 版本

    solr是一款非常优秀的全文检索服务器,最新版本在配置和前台页面上都做了较大的改动, 所以对用惯了老版本的朋友们来说,再重新配置新版本的solr,无疑又是一件痛苦的事情. 配置环境:windows   ...

  7. 图像显示与加载——opencv(转)

    cvLoadImage() 函数:IplImage* cvLoadImage("图像名称",参数): 函数作用:加载图片: 函数返回值:为IplImage结构体: 参数说明:参数值 ...

  8. 未能加载文件或程序集“DeveloperKit10.1/DotNet/ESRI.ArcGIS.ADF.Local.或它的某一个依赖项

    使用VS2010进行ArcGIS Engine 10.1进行开发过程中,出现: 错误 1 未能加载文件或程序集“file:///D:/ArcGIS/DeveloperKit10.0/DotNet/ES ...

  9. self.view 的不当操作造成死循环

    如题,在创建ContentView的时候,例子如下 NSString *viewClassName = NSStringFromClass([self class]); viewClassName = ...

  10. <转>thinkphp的各种内部函数 D()、F()、S()、C()、L()、A()、I()详解

    D.F.S.C.L.A.I 他们都在functions.php这个文件家下面我分别说明一下他们的功能 D() 加载Model类M() 加载Model类 A() 加载Action类L() 获取语言定义C ...