Search code examples
c#wpfblend

WPF trigger animation from code


I was reading many similar q&a but I didn't get answer I'm searching for. So, I'm making "homework" in Microsoft Bled, I really like storyboards and I know how to trigger them with button click, but does anyone know how to start an animation in c# for example in if sentence.

Thanks for answers and time spend in advance!


Solution

  • You´re looking for this thread.


    Another way would be:

    Storyboard sb = this.FindResource("Storyboard1") as Storyboard;
    if (sb != null){ BeginStoryboard(sb); }