Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have TextBlock In My Application . I Want TranslateTransform Animation Each of Word In My TextBlock . Like Text Effect's Exist In PowerPoint .

example : each of word move 20px to up and return to last position
Posted

A separate word is not an object, so there is nothing to animate. At best, you can animate the whole content of the instance of TextBlock by animating its Padding property. If you really want to animate words freely, do the following: put each word in a separate instance of TextBlock, put these instances on the Canvas and animate the location of those instances of TextBlock independently.

—SA
 
Share this answer
 
With My Research I Found Sample From Microsoft That I Deduce How I Can Do This Work.

First we define TextEffects For TextBlock :

C#
<TextBlock.TextEffects>
                   <TextEffectCollection>
                                            <TextEffect PositionCount="1" x:Name="TxtEffect">
                                                <TextEffect.Transform>
                                                    <TranslateTransform x:Name="Transform" X="0" Y="0"></TranslateTransform>
                                                </TextEffect.Transform>
                                            </TextEffect>
                                        </TextEffectCollection>
    </TextBlock.TextEffects>



Second We Define,s This Animations:

1)Animation For Increase PositionCount With Int32AnimationUsingKeyFrames And Define's
Int32AnimationUsingKeyFrames.KeyFrames The Number Of Words Exist In Text

2)Animation For TranslateTransform To Move Each Word

Example For Three Word :

C#
<BeginStoryboard>
                                   <Storyboard RepeatBehavior="Forever">
                                       <DoubleAnimation Storyboard.TargetName="Transform" Storyboard.TargetProperty="Y" From="0" To="20" BeginTime="0:0:0" Duration="0:0:0.25"/>
                                       <DoubleAnimation Storyboard.TargetName="Transform" Storyboard.TargetProperty="Y" From="20" To="-20" BeginTime="0:0:0.25" Duration="0:0:0.5" />
                                       <DoubleAnimation Storyboard.TargetName="Transform" Storyboard.TargetProperty="Y" From="-20" To="0" BeginTime="0:0:0.75" Duration="0:0:0.25" />
                                   </Storyboard>
</BeginStoryboard>

<BeginStoryboard Name="TxtEf">
              <Storyboard>
                       <Int32AnimationUsingKeyFrames Storyboard.TargetName="TxtEffect"
                                                                     Storyboard.TargetProperty="PositionStart"
                                                                     Duration="0:0:2.5" AutoReverse="True" RepeatBehavior="Forever">
                                           <Int32AnimationUsingKeyFrames.KeyFrames>

                                               <DiscreteInt32KeyFrame Value="0" KeyTime="0:0:0" />
                                               <DiscreteInt32KeyFrame Value="1" KeyTime="0:0:1" />
                                               <DiscreteInt32KeyFrame Value="2" KeyTime="0:0:2" />

                                           </Int32AnimationUsingKeyFrames.KeyFrames>

                         </Int32AnimationUsingKeyFrames>
              </Storyboard>



Hope To Use.
 
Share this answer
 
Comments
RaviRanjanKr 29-Nov-11 15:07pm    
A suggestion :- its not a good practice to post your feedback or comment as an answer. you can use have a question or Comment.

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