locked
problem with silverlight "load animation" RRS feed

  • Question

  • hi guys,


    I've got a problem with my animation: this animation works fine in my splashPage but not in my silverlight app. it show itself when the frame is "navigating" and stops when the navigation is completed. the problem is that the animation is not "animated"!!! it doesn't want to move!!!!


    someone can tell me why and if there is something that fix the problem?

    thanks

    Monday, November 15, 2010 5:04 AM

Answers

  • As fare as I do understand you correctly, the problem is that you are loading a list of images in another control at the same time. Loading several image means that the images are rendered by the UI thread. So when you want to start a storyboard at the same time, while the UI thread is loading the images and waiting to completed the loading to render the images you are loading, the animation won't start because silverlight might not be ready to render.

    Maybe you should try to listen to CompositionTarget.Rendering event, add a handler to this event and start the storyboard when silverlight is ready to render again. And/or you should load the images from a background thread.

    Tuesday, February 8, 2011 1:59 PM

All replies

  • What kind of loading control are you using? There may be a problem in the control itself. Another thing I've found out is that depending on what you are doing, the UI thread may get locked and thus preventing any changes in the UI. Could this be the problem in your case? Can you show us some code around the problem?

    Monday, November 15, 2010 5:43 AM
  • well when i am navigating to ,as you can see down below, begin the animation but in UI it doesn't perhaps because

    at the same time I load, in another control, a list of images.


    (ruotatore is an UserControl that contains the objects animated)
    void frame_Navigating(object sender.NavigationEventArgs e)
    {
        this.ruotatore.Visibility = Visibility.Visible;
        this.ruotatore.IniziaAnimazione();  //Begin animation
    }
    
    void frame_Navigated(object sender.NavigationEventArgs e)
    {
        this.ruotatore.TerminaAnimazione();  //stop animation
        this.ruotatore.Visibility = Visibility.Collapsed;
    }



    I normally use .GIF files in other non-silverlight rpoject but silverlight does not support them.

    how can i solve it?



    Tuesday, November 16, 2010 2:55 AM
  • I suspect the animation doesn't start because the UI thread is being locked by the other operation where you load the images. Try to disable the image loading for testing and see if you can get the animation to start. Use ie. Thread.Sleep to simulate long lasting operation. 

    If this works, then we've located the problem and need to find a way to load the images in a way that it doesn't lock the UI thread.

    Wednesday, November 17, 2010 1:01 AM
  • ok thanks a lot for your patience now I try :)

    Wednesday, November 17, 2010 3:02 AM
  • ok i dpn't get it... even with thread.sleep it stays immobile

    Monday, November 22, 2010 5:10 AM
  • Hi,

    Based on the code you post above, I didn's see any problem in it.

    I suggest you try use a button click event to control the animation and check if it loads and starts properly.

    In this way we can judge if it is because Animation control itself or navigation event.

    I normally use .GIF files in other non-silverlight rpoject but silverlight does not support them.

    how can i solve it?

    If the .gif file is a static image, you will need to open it in Paint and in save-as dialog choose .jpg or bmp in file format drop down.

    If it is a animated GIF, you may need to program it by yourself using double animation.


    Hope this helps


    Monday, November 22, 2010 11:00 AM
  • Re SimoPx:

    I normally use .GIF files in other non-silverlight rpoject but silverlight does not support them. how can i solve it?

    Shi Ding is right.
    Silverlight doesn't support .gif animation.
    So depending on the level of complexity of your animation... and
    also if you still have the original images used in your animation
    (I know I always do...;)  then it's relatively easy to recreate
    a similar replica of your animation in Expression Blend.
    Once your animation is built, you can simply associate it with
    a page_load or any other event.

    Ex:
    ...
    InitializeComponent;
    myAnimation.Begin();
    ...

    Hope this helps

    Wednesday, November 24, 2010 7:02 PM
  • yes I know that silverlight does not support gif. the problem to solve is described above ;) .


    i have already my animation, the problem is that it is not moving when i tell it to begin the animation.

    Thursday, November 25, 2010 3:47 AM
  • As fare as I do understand you correctly, the problem is that you are loading a list of images in another control at the same time. Loading several image means that the images are rendered by the UI thread. So when you want to start a storyboard at the same time, while the UI thread is loading the images and waiting to completed the loading to render the images you are loading, the animation won't start because silverlight might not be ready to render.

    Maybe you should try to listen to CompositionTarget.Rendering event, add a handler to this event and start the storyboard when silverlight is ready to render again. And/or you should load the images from a background thread.

    Tuesday, February 8, 2011 1:59 PM
  • yes you get it :) that was my problem :) thanks a lot :D
    Wednesday, February 9, 2011 5:49 AM
  • yes you get it :) that was my problem :) thanks a lot :D

    Wednesday, February 9, 2011 5:49 AM