2012-04-04 140 views
1

在我的Silverlight应用程序中,我通过Blend手动创建了一个滑板。按下按钮点击.xaml故事板

<UserControl.Resources> 
<Storyboard x:Name="Swivel"> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="Menus"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-90"/> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Menus"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="1"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/> 
      </DoubleAnimationUsingKeyFrames> 
     </Storyboard> 
</UserControl.Resources> 

我想按下按钮点击此故事板。有没有办法做到这一点,而无需在.cs中编写故事板,然后storyboard.Start()等?

+2

你可以在按钮单击中执行'SwivelDissapear.Begin()'。 – Zabavsky 2012-04-04 11:19:02

回答

1

您想将ControlStoryboardAction绑定到按钮的Click事件。 Here's a quick guide关于如何在Blend中添加动作。如果您没有在资产面板中看到ControlStoryboardAction,只需添加对Microsoft.Expression.Interactions.dll的引用即可。你可以在你的Blend SDK文件夹中找到这个文件夹(在我的Win7 x64系统上,在C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v5.0\Libraries文件夹中)