在自定义的Page或者基类LayoutAwarePage(如果继承了这个类的话)的OnNavigateTo事件中,可以定义这么一个动画效果:
修改页面的透明度,从透明渐变为不透明。
建议尽量使用基于LayoutAwarePage(基本页)的页面Page,因为许多导航的功能以及页面生命周期的管理都已经封装得比较完善了。在页面的跳转过程中,利用其提供的LoadState()和SaveState()可以做页面参数的传递以及缓存。
说偏了,下面是一个比较简单的动画效果:
/// <summary>
/// 创建进入视图时的渐变动画
/// </summary>
private void ShowNavigationStoryBoard()
{
Storyboard story = new Storyboard();
DoubleAnimation animation;
animation = new DoubleAnimation();
animation.From = 0.3;
animation.To = 1;
animation.Duration = new Duration(TimeSpan.FromMilliseconds(300));
Storyboard.SetTarget(animation, this);
Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Opacity)").Path);
story.Children.Add(animation);
story.Begin();
}其中,ShowNavigationStoryBoard()这个方法我写到了OnNavigateTo事件里面。

本文介绍了一种在Windows Phone应用中实现页面加载时渐显动画的方法。通过修改页面的透明度,使其从完全透明过渡到完全不透明,从而达到平滑的视觉效果。此动画效果适用于基于LayoutAwarePage的基本页面。

被折叠的 条评论
为什么被折叠?



