这是我的页面,显示了用户的当前位置:
在地图控件的左下角,有一个展开按钮。单击时,地图控件应展开为全屏,并且按钮应更改为折叠按钮。这很容易,但我想为展开和折叠过程制作动画。我怎样才能做到这一点?
这是我的页面,显示了用户的当前位置:
在地图控件的左下角,有一个展开按钮。单击时,地图控件应展开为全屏,并且按钮应更改为折叠按钮。这很容易,但我想为展开和折叠过程制作动画。我怎样才能做到这一点?
有关 XAML 元素的动画属性的概述,请查看此处...
http://windowsphonegeek.com/articles/wp7-animations-in-depthndash-overview-and-getting-started
对于地图,这里有一些 C# 代码来动画它的“高度”属性......
// assumes Map element is called 'map'
double height = map.Height;
double from, to;
// animate from 150 to 800, or vice versa
if (height == 150)
{
from = 150;
to = 800;
}
else
{
from = 800;
to = 150;
}
Storyboard sb = new Storyboard();
DoubleAnimation fillHeightAnimation = new DoubleAnimation();
fillHeightAnimation.From = from;
fillHeightAnimation.To = to;
fillHeightAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.3));
Storyboard.SetTarget(fillHeightAnimation, map);
Storyboard.SetTargetProperty(fillHeightAnimation, new PropertyPath("Height"));
sb.Children.Add(fillHeightAnimation);
sb.Begin();