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}" />


Is there a way to disable animation in xaml ..?


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:

        <Condition Property="IsActive" Value="True"/>
        <BeginStoryboard Storyboard="{StaticResource StoryBoard1}"/>
        <BeginStoryboard Storyboard="{StaticResource StoryBoard2}"/>




All Articles