locked
My animation doesn't start. RRS feed

  • Question

  • Hi everyone from italy.. This is my first post to silverlight forum.

    I'm here because i have create an animation with silverlight beta 2 tool 2 with expression blend june 2008, 

    and when i test this one from visual studio 2008 project, this doesn't work, is static.

    I've applied the code into page.xaml.cs public page()

    namespace SilverlightApplication5
    {
        public partial class Page : UserControl
        {
            public Page()
            {
                InitializeComponent();
                this.Loaded += new RoutedEventHandler(Page_Loaded);  

    mystoryboard.Begin();  
            }

            void Page_Loaded(object sender, RoutedEventArgs e)
            {
                throw new NotImplementedException();


            }

         }
    }

     

    This is the result

     

     

    or the static first frame of my animation...

     

    Someone know the solution please?...thank you so much.. 

    Monday, August 11, 2008 2:57 AM

Answers


  •         void Page_Loaded(object sender, EventArgs e)
            {
                throw new NotImplementedException();
                myanimation.Begin();
            }

    It seems that, in the Page_Loaded event you are throwing exception first & then calling the Begin() for the storyboard.
    Try using the following code: 

    1    namespace SilverlightApplication5
    2    {
    3        public partial class Page : UserControl
    4        {
    5            public Page()
    6            {
    7                InitializeComponent();
    8                this.Loaded += new RoutedEventHandler(Page_Loaded);
    9    
    10           }
    11   
    12           void Page_Loaded(object sender, EventArgs e)
    13           {
    15               myanimation.Begin();
    16           }
    17   
    18    
    19   
    20       }
    21   }
    
    In the Storyboard set the RepeatBehavior = "Forever".

    Wednesday, August 13, 2008 7:26 AM

All replies

  •  Documentation says that you shouldn't try to begin your animation in constructor, because it will fail.

    Try to move the animation.begin() part to Page_Loaded() eventhandler.

     

     http://msdn.microsoft.com/en-us/library/cc189069(VS.95).aspx

    hope this helps :)

    Monday, August 11, 2008 3:04 AM
  •  Hi, i've chanched the code like there:

    namespace SilverlightApplication5
    {
        public partial class Page : UserControl
        {
            public Page()
            {
                InitializeComponent();
                this.Loaded += new RoutedEventHandler(Page_Loaded);

            }

            void Page_Loaded(object sender, EventArgs e)
            {
                throw new NotImplementedException();
                myanimation.Begin();
            }

     

        }
    }

     

    but animation still static, not start :° 

    Monday, August 11, 2008 3:15 AM
  • Hi, Change it like this.

    \namespace SilverlightApplication5

     { public partial class Page : UserContro

    l { public Page()

     { InitializeComponent();

    this.Loaded += new RoutedEventHandler(Page_Loaded);

    this.myanimation.Completed+= new EventHandler(myanimation_Completed);

    }

    void my_Completed(object sender, EventArgs e)

    {

    myanimation.Begin();

    }

    void Page_Loaded(object sender, EventArgs e)

    {

    myanimation.Begin();

     }

    }

    }

    Try this out.Probably your animation duration might be less so it might be playing it before you have seen that.So in Completed handler i am starting it again and again.

     

    If this answers your question mark it as answer.

    Monday, August 11, 2008 3:23 AM
  •  Check if the animation is working in any button click event..

    If it works then it will work in page loaded event also.. 

    Monday, August 11, 2008 3:28 AM
  • This is an example of my work: i've installed the silverlight 2 beta tools for visual studio 2008, i've opened a new c# project silverlight application and openede

    the page.xaml in expression blend 2.5 june 2008 prewiev and edited the layout, adding 3 small image with fade effect thanks to opacity manipolation for try.

     

    I've saved the page.xaml and i've returned to visual studio to modify de page.xaml.cs for add the command storyboard.begin() and press f5 to try application, and doesn't work.

     

    This is my iter.

     

     


    Monday, August 11, 2008 3:29 AM
  • Hi, Change it like this.

    \namespace SilverlightApplication5

     { public partial class Page : UserContro

    l { public Page()

     { InitializeComponent();

    this.Loaded += new RoutedEventHandler(Page_Loaded);

    this.myanimation.Completed+= new EventHandler(myanimation_Completed);

    }

    void my_Completed(object sender, EventArgs e)

    {

    myanimation.Begin();

    }

    void Page_Loaded(object sender, EventArgs e)

    {

    myanimation.Begin();

     }

    }

    }

    Try this out.Probably your animation duration might be less so it might be playing it before you have seen that.So in Completed handler i am starting it again and again.

     

    If this answers your question mark it as answer.

     

     

    Hi and thanks for your answers, but also whit this code doesn't work. 

    Monday, August 11, 2008 3:34 AM
  • X___________x

     

    Now i remake another animation without change the layeroot properties and now the animation work..

    I'm without word, after hours to search answers, and te risk to be crazy tonight -.-°°°°°°°°

    Well..I ask to be forgiven everyone for the disturb..

    Hope to talk you soon..
     

    Monday, August 11, 2008 4:08 AM

  •         void Page_Loaded(object sender, EventArgs e)
            {
                throw new NotImplementedException();
                myanimation.Begin();
            }

    It seems that, in the Page_Loaded event you are throwing exception first & then calling the Begin() for the storyboard.
    Try using the following code: 

    1    namespace SilverlightApplication5
    2    {
    3        public partial class Page : UserControl
    4        {
    5            public Page()
    6            {
    7                InitializeComponent();
    8                this.Loaded += new RoutedEventHandler(Page_Loaded);
    9    
    10           }
    11   
    12           void Page_Loaded(object sender, EventArgs e)
    13           {
    15               myanimation.Begin();
    16           }
    17   
    18    
    19   
    20       }
    21   }
    
    In the Storyboard set the RepeatBehavior = "Forever".

    Wednesday, August 13, 2008 7:26 AM