Reputation: 89
For example, the translate transform animation is running, I want to hold on the animation, but not to stop it, how to do with that?
Upvotes: 3
Views: 248
Reputation: 22702
In order to pause in animation worked correctly you need to call the Begin() method from the code, such as Loaded
event handler (eg: Window_Loaded
), because - quote from MSDN
:
When you Begin a storyboard that was paused, it appears to resume and restart. However, that is not what actually happens. The Begin method actually replaces itself with an unpaused version. Each time the Begin method is called, clock objects are created for the storyboard. These clocks are distributed to the properties they animate. So, when the Begin method is called again, it does not restart its clocks; it replaces them with new clocks.
Example:
<Window.Resources>
<Storyboard x:Key="SomeStoryboard">
...
</Storyboard>
</Window.Resources>
In Loaded
event or something else:
MyStoryboard = (Storyboard)this.FindResource("SomeStoryboard");
MyStoryboard.Begin();
And in Pause
Button:
private void ButtonPause_Click(object sender, RoutedEventArgs e)
{
MyStoryboard.Pause();
}
For more information, please see:
Upvotes: 1