0

I have multiple pages in my WP7 app and I move in and out of apps by selections made during usage of the app. it is a data heavy app, but i'm not doing anything else but fill up the control by using its own ViewModel.

The ForwardIn transition animation fails to show up - which results in an ugly black screen pause for about 1.5 seconds and the page suddenly seems to popup. I have a white background in some pages so after appearing the phone tries to adjust the brightness automatically, which looks bad too. is there anythign specific I need to look out for?

Is there a way I can preload the page before navigation so that it happens smoothly, I'm using the performance progress bar in the previous pages to load data anyway. are there any ways to profile this page load so that I can check what took the most time.

Jay Kannan
  • 1,372
  • 3
  • 14
  • 30
  • The other animations are working when I hit back for example, and I followed the standard way of mapping from the sameples. – Jay Kannan Nov 22 '11 at 11:55

1 Answers1

0

I have seen this effect a lot when binding to lists. What I do is delay the binding until after the navigation/animation is complete. I usually show a progress bar after animation completes, wait about 50ms on a background thread to allow the progress bar to update it's UI and then bind to the list and hide the progress bar.

Here is the code I run when the animation completes:

progressBar.IsIndeterminate = true;
progressBar.Visibility = Visibility.Visible;
SynchronizationContext context = SynchronizationContext.Current;
Thread t = new Thread(() =>
{
    /* Allow the UI to catch up */
    Thread.Sleep(50);
    context.Post((state) =>
    {
        list.ItemsSource = dataSource;

        /* Hide the progress bar */
        progressBar.IsIndeterminate = false;
        progressBar.Visibility = Visibility.Collapsed;
    }, null);
});
t.IsBackground = true;
t.Start();
calum
  • 1,580
  • 10
  • 11
  • is it safe to put this into the binding functions? I've assigned them most in the XAML files, do I need to move them out now? – Jay Kannan Nov 22 '11 at 15:50
  • the progressbar is really in the previous page, I wont have control over it. – Jay Kannan Nov 22 '11 at 15:52
  • You will need to remove the binding in the xaml otherwise the list will be bound before the animation is finished. The progress bar was just an example, I always overlay the list with a progress bar when loading like this. – calum Nov 22 '11 at 18:34
  • I got the animation example from a dev blog online, using a standard turnstile template. it works fine when I use it on a sample. maybe I'll try what you said. – Jay Kannan Nov 23 '11 at 09:29
  • what's the best way to bind DataContext in the code-behind especially in this context with regards to animation? Also, I have some user controls in the pivot that enables this animation. everything seems to be fine in most pages except this one - which is unfortuantely the main search form. – Jay Kannan Nov 23 '11 at 11:20
  • Can this be solved by using the IsAsync property? Ill try it out and see. – Jay Kannan Nov 28 '11 at 09:58