Click here to Skip to main content
16,017,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have Animation In My ResourceDictionary But I Want Call Animation In My C# Code. This ResourceDictionary Add To My Resources App

Example:

C#
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<BeginStoryboard x:Key="PuzzleFall">
                <Storyboard Storyboard.TargetName="RenderT" Storyboard.TargetProperty="X">
                    <DoubleAnimationUsingKeyFrames  Duration="0:0:3" BeginTime="0:0:0">
                        <SplineDoubleKeyFrame Value="0" KeySpline="1 0,0.95 0" KeyTime="0:0:3"/>
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames BeginTime="0:0:3.06" Duration="0:0:1.5">
                        <SplineDoubleKeyFrame Value="50" KeySpline="0 1,0 1" KeyTime="0:0:1.5"/>
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames BeginTime="0:0:3.08" Duration="0:0:1">
                        <SplineDoubleKeyFrame Value="0" KeySpline="1 0,1 0" KeyTime="0:0:1"/>
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames BeginTime="0:0:4.1" Duration="0:0:1">
                        <SplineDoubleKeyFrame Value="15" KeySpline="0 1,0 1" KeyTime="0:0:1"/>
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames BeginTime="0:0:4.15" Duration="0:0:0.5">
                        <SplineDoubleKeyFrame Value="0" KeySpline="1 0,1 0" KeyTime="0:0:0.5"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>

</BeginStoryboard>
</ResourceDictionary>


Then I Want Run This Animation In C# Code.

Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 26-Nov-11 19:56pm    
Not a question! What do you want to achieve and what problem do you face?
--SA

As described here[^], something like
C#
Storyboard sbdLabelRotation
    = (Storyboard) FindResource( "sbdLabelRotation" );

  sbdLabelRotation.Begin( this );
should do the trick.
 
Share this answer
 
Comments
Amir Mahfoozi 26-Nov-11 23:53pm    
+5 I agree with you.
Look into the "Using Resource Files in C#" section of the below article,
Using a Resource Dictionary in WPF[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900