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. C#
  4. Starting animation defined in XAML from code

Starting animation defined in XAML from code

Scheduled Pinned Locked Moved C#
wpfcsharpdatabasehelpquestion
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.
  • D Offline
    D Offline
    donovan solms
    wrote on last edited by
    #1

    Hi, I've posted this on the Microsoft forums as well but have not received any usable answer. I have a storyboard in XAML (in a DataTemplate) that I need to start from code. Now I've given up on that idea and rather went with an event to start it. Note: This is WPF. instead of: I now have: gestureMade is an event I created. Which is defined in code as: public static readonly RoutedEvent gestureMadeEvent = EventManager.RegisterRoutedEvent("gestureMade", RoutingStrategy.Bubble, typeof(gestureMadeHandler), typeof(TouchActor)); public delegate void gestureMadeHandler( object sender, GestureEventArgs e ); public event gestureMadeHandler gestureMade { add { AddHandler(gestureMadeEvent, value); } remove { RemoveHandler(gestureMadeEvent, value); } } I know the event gets raised because I have a MessageBox that pops up in the handler. The problem is that it doesn't trigger the animation. Am I missing something? rather have something you don't need, than need something you don't have

    C 1 Reply Last reply
    0
    • D donovan solms

      Hi, I've posted this on the Microsoft forums as well but have not received any usable answer. I have a storyboard in XAML (in a DataTemplate) that I need to start from code. Now I've given up on that idea and rather went with an event to start it. Note: This is WPF. instead of: I now have: gestureMade is an event I created. Which is defined in code as: public static readonly RoutedEvent gestureMadeEvent = EventManager.RegisterRoutedEvent("gestureMade", RoutingStrategy.Bubble, typeof(gestureMadeHandler), typeof(TouchActor)); public delegate void gestureMadeHandler( object sender, GestureEventArgs e ); public event gestureMadeHandler gestureMade { add { AddHandler(gestureMadeEvent, value); } remove { RemoveHandler(gestureMadeEvent, value); } } I know the event gets raised because I have a MessageBox that pops up in the handler. The problem is that it doesn't trigger the animation. Am I missing something? rather have something you don't need, than need something you don't have

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      WPF forums on MSDN are close to useless unless you have a week to wait, in my experience. The way to start a storyboard in code is something like this: BeginStoryboard storyboardShow = Resources["showAnimation"] as BeginStoryboard; storyboardShow.Storyboard.Begin(this);

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      D 1 Reply Last reply
      0
      • C Christian Graus

        WPF forums on MSDN are close to useless unless you have a week to wait, in my experience. The way to start a storyboard in code is something like this: BeginStoryboard storyboardShow = Resources["showAnimation"] as BeginStoryboard; storyboardShow.Storyboard.Begin(this);

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        D Offline
        D Offline
        donovan solms
        wrote on last edited by
        #3

        thanks for the reply. The problem is that the BeginStoryboard is in a Trigger, which is far nested into a DataTemplate so I cannot give it a key. I got to the BeginStoryboard through code by navigating through the template and registering everything that I need. So when I finally call story.Storyboard.Begin(this); I get no errors, the code is run (checked via tracing through it) but the animation doesn't happen. Any reason for this? Wrong containingObject?

        rather have something you don't need, than need something you don't have

        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