4

当我在我的应用程序内向左或向右滑动时,如何获得翻页效果?我以前见过它,但是在阅读页面过渡和故事板动画时,我只是不明白它们是如何实现的。除了简单地更改元素的背景颜色之外,还没有在 MSDN 上找到任何显示任何内容的页面。

你以前做过吗,或者你知道任何参考资料、样本或有什么可以分享的吗?

4

2 回答 2

6

Step1: Create a Windows Phone 7 application project and add reference to Microsoft.Phone.Controls.Toolkit.dll.

Step2: Go to App.xaml.cs and set your application's RootFrame property to an instance of TransitionFrame (in App.InitializePhoneApplication of the App.xaml.cs) if you want to have automatically animated Page transitions:

private void InitializePhoneApplication()
{
if (phoneApplicationInitialized)
    return;

// Create the frame but don't set it as RootVisual yet; this allows the splash
// screen to remain active until the application is ready to render.
RootFrame = new TransitionFrame();
RootFrame.Navigated += CompleteInitializePhoneApplication;

// Handle navigation failures
RootFrame.NavigationFailed += RootFrame_NavigationFailed;

// Ensure we don't initialize again
phoneApplicationInitialized = true;
}

Step3: Go to your MainPage.xaml and add the "toolkit" prefix declaration

<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>
于 2013-12-02T06:12:52.940 回答
6

如果您使用 Windows Phone Toolkit,则可以操作许多导航转换效果。它很容易安装,您还可以运行示例并检查转换以查看其中一个是否满足您的需求。

http://phone.codeplex.com/

安装它 https://www.nuget.org/packages/WPtoolkit

你也应该检查这个 http://blogs.windows.com/windows_phone/b/wpdev/archive/2012/11/20/windows-phone-toolkit-overview.aspx

于 2013-07-23T22:07:18.177 回答