我在XAML中使用Microsoft Expression Blend有一个故事板,我想在C#中调用这个故事板,我已经研究了一天左右,我似乎无法找到答案。我就在这时
XAML:
<UserControl.Resources>
<Storyboard x:Key="LoginClose">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="LoginControl">
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="LoginControl">
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LoginControl">
<DiscreteObjectKeyFrame KeyTime="0:0:0.4" Value="{x:Static Visibility.Visible}"/>
<DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
代码背后:
private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e){
Storyboard Test = this.FindResource(" LoginClose ") as Storyboard;
Test.Begin();
}
这实际上是编译的,这比我发现的其他许多帮助要多,但是当我点击这个方法的按钮时,我的程序就没有响应了。任何人都可以帮忙吗?
答案 0 :(得分:1)
Neverymind ......我想通了......这里的空间.FindResource(“LoginClose”)对那些空格是不准确的。刚刚制作它(“LoginClose”)并且故事板工作得很好