我有这个动画,它在加载时开始:
<Grid.Triggers>
<EventTrigger RoutedEvent= "Canvas.Loaded">
<BeginStoryboard>
<Storyboard x:Name="sb1" RepeatBehavior="Forever">
<DoubleAnimation Name="earth" From="0" To="-360" Duration="0:0:10" AutoReverse="False" Storyboard.TargetName="rotation" Storyboard.TargetProperty="Angle" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
如何停止此操作并使用我的开关案例(如鼠标悬停)输入另一个事件触发器。 我正在使用kinect音频源,因此当用户说“美国”或“欧洲”时,动画应该停留在该大陆。
<EventTrigger RoutedEvent= ""><!--switch case "AMERICA" -->
<BeginStoryboard>
<Storyboard x:Name="sb2">
<DoubleAnimation Name="america" To="0" Duration="0:0:5" AutoReverse="False" Storyboard.TargetName="rotation" Storyboard.TargetProperty="Angle" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
我试过这个,但不起作用:
switch (e.Result.Semantics.Value.ToString())
{
case "AMERICA":
americaSpan.Foreground = Brushes.DeepSkyBlue;
americaSpan.FontWeight = FontWeights.Bold;
Storyboard storyBoard1 = (Storyboard)FindName("sb1");
Storyboard storyBoard2 = (Storyboard)FindName("sb2");
storyBoard1.Stop();
storyBoard2.Begin();
break;
}