Disable animation in XAML?
If I have a storyboard animation defined in xaml resources, how can I disable it?
For example, if I have something like this in the UserControl.Resources section:
<Storyboard x:Key="MyKey">
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.5" DecelerationRatio="1" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
Is there a way to disable animation in xaml ..?
+3
source to share
1 answer
The XAML way is described here: http://msdn.microsoft.com/en-us/library/ms741997.aspx
The code behind: You can use FindResource to get a StoryBoard, throw it at the StoryBoard and call Stop.
Edit: See http://www.galasoft.ch/mydotnet/articles/article-2006102701.aspx for a deeper look at storyboard and code.
Edit: Using properties in triggers:
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsActive" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource StoryBoard1}"/>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource StoryBoard2}"/>
</MultiTrigger.ExitActions>
</MultiTrigger>
+1
source to share