Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Apply two animations to a text block simultanously

Apply two animations to a text block simultanously

Scheduled Pinned Locked Moved WPF
wpf
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WBurgMo
    wrote on last edited by
    #1

    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 1 Reply Last reply
    0
    • W WBurgMo

      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 Offline
      I Offline
      Insincere Dave
      wrote on last edited by
      #2

      You need to set the PositionCount of the TextEffect. te.PositionCount = this.gameOver.Text.Length;

      W 1 Reply Last reply
      0
      • I Insincere Dave

        You need to set the PositionCount of the TextEffect. te.PositionCount = this.gameOver.Text.Length;

        W Offline
        W Offline
        WBurgMo
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups