windows phone 頁面切換 動畫

來源:互聯網
上載者:User

首先將App.xaml.cs中 InitializePhoneApplication() 函數裡的RootFrame修改成RootFrame=new TransitionFrame();

  其次在XAML中添加 xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

  最後在Page元素下添加

<toolkit:TransitionService.NavigationInTransition>
    <toolkit:NavigationInTransition>
        <toolkit:NavigationInTransition.Backward>
            <toolkit:TurnstileTransition Mode="BackwardIn"/>
        </toolkit:NavigationInTransition.Backward>
        <toolkit:NavigationInTransition.Forward>
            <toolkit:TurnstileTransition Mode="ForwardIn"/>
        </toolkit:NavigationInTransition.Forward>
    </toolkit:NavigationInTransition>
</toolkit:TransitionService.NavigationInTransition>
<toolkit:TransitionService.NavigationOutTransition>
    <toolkit:NavigationOutTransition>
        <toolkit:NavigationOutTransition.Backward>
            <toolkit:TurnstileTransition Mode="BackwardOut"/>
        </toolkit:NavigationOutTransition.Backward>
        <toolkit:NavigationOutTransition.Forward>
            <toolkit:TurnstileTransition Mode="ForwardOut"/>
        </toolkit:NavigationOutTransition.Forward>
    </toolkit:NavigationOutTransition>
</toolkit:TransitionService.NavigationOutTransition>

  toolkit提供了5種動畫效果 1.RollTransition 2.RotateTransition 3.SlideTransition 4.SwivelTransition 5.TurnstileTransition;我們還可以通過繼承TransitionElement實現自己的動畫。

  如果很多頁面需要這些效果的話,也可以將效果作為樣式添加到資源檔中以提供其他頁面使用

<Application.Resources>
            <Style x:Key="TransitionPageStyle" TargetType="phone:PhoneApplicationPage">
                <Setter Property="toolkit:TransitionService.NavigationInTransition">
                    <Setter.Value>
                        <toolkit:NavigationInTransition>
                        <toolkit:NavigationInTransition.Backward>
                            <toolkit:TurnstileTransition Mode="BackwardIn"/>
                        </toolkit:NavigationInTransition.Backward>
                        <toolkit:NavigationInTransition.Forward>
                            <toolkit:TurnstileTransition Mode="ForwardIn"/>
                        </toolkit:NavigationInTransition.Forward>
                    </toolkit:NavigationInTransition>
                </Setter.Value>
                </Setter>
                <Setter Property="toolkit:TransitionService.NavigationOutTransition">
                    <Setter.Value>
                        <toolkit:NavigationOutTransition>
                        <toolkit:NavigationOutTransition.Backward>
                            <toolkit:TurnstileTransition Mode="BackwardOut"/>
                        </toolkit:NavigationOutTransition.Backward>
                        <toolkit:NavigationOutTransition.Forward>
                            <toolkit:TurnstileTransition Mode="ForwardOut"/>
                        </toolkit:NavigationOutTransition.Forward>
                    </toolkit:NavigationOutTransition>
                </Setter.Value>
                </Setter>
            </Style>
</Application.Resources>

 

 http://silverlightchina.net/html/zhuantixilie/winphone7/2012/0722/17574.html

 在xaml檔案中:

toolkit:TransitionService.NavigationInTransition 進來的動畫 
    toolkit:NavigationInTransition    
        toolkit:NavigationInTransition.Backward  後退進入動畫 
        toolkit:NavigationInTransition.Forward   前進進入動畫

toolkit:TransitionService.NavigationOutTransition 出去的動畫 
    toolkit:NavigationOutTransition 
        toolkit:NavigationOutTransition.Backward 後退退齣動畫 
        toolkit:NavigationOutTransition.Forward  前進退齣動畫

 

 

動畫枚舉


toolkit:SlideTransition 飛入動畫 
    Mode 
        SlideUpFadeIn         向上飛入 
        SlideUpFadeOut         向上飛出 
        SlideDownFadeIn     向下飛入 
        SlideDownFadeOut     向下飛出 
        SlideLeftFadeIn        向左飛入 
        SlideLeftFadeIn        向左飛出 
        SlideRightFadeIn    向右飛入 
        SlideRightFadeIn    向右飛出

toolkit:RollTransition        360旋轉動畫

toolkit:RotateTransition    旋轉動畫 
    Mode 
        In180Clockwise        180順時針轉入 
        Out180Clockwise        180順時針轉出 
        In180Counterclockwise    180逆時針轉入 
        Out180Counterclockwise    180逆時針轉出 
        In90Clockwise        90順時針轉入 
        Out90Clockwise        90順時針轉出 
        In90Counterclockwise    90逆時針轉入 
        Out90Counterclockwise    90逆時針轉出

toolkit:SwivelTransition    垂直翻轉動畫 
    Mode 
        BackwardIn        向後翻轉入 
        BackwardOut        向後翻轉出 
        ForwardIn        向前翻轉入 
        ForwardOut        向前翻轉出 
        FullScreenIn        全屏翻轉入 
        FullScreenOut        全屏翻轉出 
    
toolkit:TurnstileTransition    翻頁動畫 
    Mode 
        BackwardIn        向後翻入 
        BackwardOut        向後翻出 
        ForwardIn        向前翻入 
        ForwardOut        向前翻出

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.