假设有一个动画会持续,例如 10 秒,当鼠标进入相关控件时我如何暂停(而不是完全停止)它,然后当鼠标离开时,动画继续完成其余部分?
问问题
133 次
1 回答
1
使用PauseStoryboard和ResumeStoryboard类。例如:
<Control>
<Control.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard x:Name="theStoryboard">
...
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseEnter">
<PauseStoryboard BeginStoryboardName="theStoryboard"/>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<ResumeStoryboard BeginStoryboardName="theStoryboard"/>
</EventTrigger>
</Control.Triggers>
</Control>
于 2012-02-21T07:38:43.913 回答