【发布时间】:2014-09-03 08:17:47
【问题描述】:
这将用作扩展器。我想让扩展动画。 所以,我做了这个:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SuspendExpand">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.5"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Suspend"/>
<VisualState x:Name="Expand">
<Storyboard>
<DoubleAnimation Duration="0" To="439" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="MyRectangle" EnableDependentAnimation="true"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="MyRectangle" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="177" Margin="313,281,0,0" Stroke="Black" VerticalAlignment="Top" Width="342" Tapped="rectangle_Tapped"/>
和方法:
private void rectangle_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "Expand", true);
}
但是扩展不是动画的。
但是当我使用这个时:
<Page.Resources>
<Storyboard x:Name="NewStory">
<DoubleAnimation Storyboard.TargetName="MyRectangle" Storyboard.TargetProperty="Height" From="177" EnableDependentAnimation="true" To="500" Duration="0:0:1" />
</Storyboard>
</Page.Resources>
和方法:
private void rectangle_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
NewStory.Begin();
}
它是动画的。有什么不同?这是否意味着我不能使用视觉状态?
【问题讨论】:
标签: xaml animation windows-8 windows-8.1