Reputation: 1809
Let's say that there's an animation which would last, for example, 10 seconds, how can I suspend (not totally stop) it when mouse enters the relevant control, and then when mouse leaves, the animation continues to finish the rest?
Upvotes: 0
Views: 141
Reputation: 178630
Use the PauseStoryboard and ResumeStoryboard classes. For example:
<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>
Upvotes: 1