Windows phone 7 在Windows Phone 7中将控件从纵向平滑旋转到横向
我正在显示一个画布,希望它在手机从纵向旋转到横向时能够平稳地旋转90度 似乎当手机旋转时(至少在模拟器中),画布会自动旋转,但过渡不是平滑的(即从0度到90度)-我假设这是自动布局功能 我希望画布能够平稳旋转,即不会突然从0度跳到90度(就像自动布局功能那样)。我在状态管理器中设置了两个状态,并调用以下命令:Windows phone 7 在Windows Phone 7中将控件从纵向平滑旋转到横向,windows-phone-7,expression-blend,Windows Phone 7,Expression Blend,我正在显示一个画布,希望它在手机从纵向旋转到横向时能够平稳地旋转90度 似乎当手机旋转时(至少在模拟器中),画布会自动旋转,但过渡不是平滑的(即从0度到90度)-我假设这是自动布局功能 我希望画布能够平稳旋转,即不会突然从0度跳到90度(就像自动布局功能那样)。我在状态管理器中设置了两个状态,并调用以下命令: private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEven
private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
if ((e.Orientation & PageOrientation.Landscape) != 0)
{
VisualStateManager.GoToState(this, "Landscape", true);
}
else
{
VisualStateManager.GoToState(this, "Portrait", true);
}
}
我已按如下方式设置了这些之间的转换:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="OrientationStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Portrait" GeneratedDuration="0" To="Landscape">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="LayoutRoot">
<EasingDoubleKeyFrame KeyTime="0" Value="90"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualTransition>
<VisualTransition From="Landscape" GeneratedDuration="0" To="Portrait">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="LayoutRoot">
<EasingDoubleKeyFrame KeyTime="0" Value="90"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Portrait"/>
<VisualState x:Name="Landscape"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
有趣的是,过渡应该从90度开始,然后旋转回0,因为自动布局功能似乎首先开始。这是我应该做的吗
或者如何覆盖自动布局功能,以便首先触发过渡
我只在emulator中工作(等待漫长的AppHub注册过程),因此很难确定这是否是正确的方法 您可能对David Anson在这里实现的这种效果感兴趣:
它完全是开源的。VisualState有一个选项
流体动画
。谷歌it…@Ku6opr-这种评论没有建设性。链接到“流体动画”选项如何?此选项是DependencyProperty还是Blend中的某个UI元素?它是Expression Blend中“视觉状态”面板右上角的一个按钮。