I have a simple silverlight Navigation Application.
I need to start a Storyboard when a Page is navigated on a content frame.
At first everything seemed to work fine. But now I need to do some treatment (that takes about 3 seconds) when the Page loads, just before showing the Storyboard.
Now I do not see my Storyboard animation anymore. Even if the Storyboard is started after my data is loaded.
I can emulate my problem using a Thread.Sleep like that it does the same thing :
private void Page_Loaded(object sender, RoutedEventArgs e)
{
System.Threading.Thread.Sleep(3000);
Storyboard1_Test.Begin();
}
Triggering UI changes from an event handler sometimes have this kind of issues. Usually using Dispatcher.BeginInvoke method solve it.
So just try lunching
Storyboard1_Test.Begin();from theDispatcher.BeginInvokeSome code (hope you don’t mind i’m using VB.NET):
By using the dispatcher.BeginInvoke you verify that the job is excuted on the UI thread when the thread is available.