Apply two animations to a text block simultanously
-
I am trying to animate the FontSize and the rotation of a TextBlock. The FontSize animates but I can not get the text to rotate. Here is the XAML
Here is the relevant code behind
DoubleAnimation fsa = this.FindResource("StringFontSize") as DoubleAnimation; DoubleAnimation sra = this.FindResource("StringRotation") as DoubleAnimation; Storyboard sb = new Storyboard(); TextEffect te = new TextEffect(); te.Transform = new RotateTransform(0); this.gameOver.Text = "G
-
I am trying to animate the FontSize and the rotation of a TextBlock. The FontSize animates but I can not get the text to rotate. Here is the XAML
Here is the relevant code behind
DoubleAnimation fsa = this.FindResource("StringFontSize") as DoubleAnimation; DoubleAnimation sra = this.FindResource("StringRotation") as DoubleAnimation; Storyboard sb = new Storyboard(); TextEffect te = new TextEffect(); te.Transform = new RotateTransform(0); this.gameOver.Text = "G
You need to set the PositionCount of the TextEffect.
te.PositionCount = this.gameOver.Text.Length;
-
You need to set the PositionCount of the TextEffect.
te.PositionCount = this.gameOver.Text.Length;
Setting the "PositionCount" solved the problem. Thanks. Now a second problem. With the animations defined as a window resource, they run one time only. What do I have to reset in a DoubleAnimation to reuse it? For now I am creating the animations at run time. But I would like to know how to reuse an animation.