我如何从资源中触发故事板? 故事: 我写这个故事板并添加到resources()
<Ellipse.Resources>
<Storyboard x:Key="exitgo">
<DoubleAnimation Duration="00:00:00.5" Storyboard.TargetProperty="Opacity" To="1"/>
<ThicknessAnimation Duration="00:00:00.5" Storyboard.TargetProperty="Margin" To="-168,-579,-195,-631"/>
</Storyboard>
</Ellipse.Resources>
然后我从vb.net
触发它Dim openn As Storyboard = DirectCast(FindResource("exitgo"), Storyboard)
openn.Begin()
但问题出在这里,它不起作用,它只是冻结我的应用程序,没有任何错误 请注意,ellapse在资源之前有一些EventTrigger
答案 0 :(得分:-1)
你必须这样做:
private void PlayButton_Click(object sender, RoutedEventArgs e)
{
Storyboard story = (Storyboard)MyEllipse.Resources["exitgo"];
Storyboard.SetTarget(story.Children[0], MyEllipse);
Storyboard.SetTarget(story.Children[1], MyEllipse);
story.Begin();
}