WP7 Tip: Setting the Panorama Page After Tombstoning

Saturday, October 09, 2010 4:20:29 PM Categories: Silverlight WP7

I’m currently working on my demos for the Tallahassee Code Camp in a couple weeks. I ran into an issue with the Panorama Control and Tombstoning. If you aren’t doing WP7 development (or you have forgotten) “Tombstoning” is the process that your app goes through to save off state before it is removed in memory due to a Task Launcher or the user has hit the windows button. You are given a chance to save off your transient data as well as to persist any data that should be persisted.

Anyway, my tombstoning demo is on an interaction on page 2 of the Panorama (Page 1 is a simple navigation facility to show a different screen altogether). This is what happens:

Tombstoning Before After Resume

The before is on the left and the after resume is on the right. As you can see we didn’t end up on the right page of the Panorama. So I did some digging into the Panorama. Obviously if it were straight forward I wouldn’t be posting this. It turns out that there is both a SelectedIndex and a SelectedItem property. Both of which are ReadOnly (so you can get the value, but you can’t set it). There is, however, a DefaultItem property which sets which page is the first one that is visible when the page loads. It’s not 100% perfect, but it will do. Here’s my code to do this

protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
    State["PanoramaSelectedItem"] = mainPanorama.SelectedIndex;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    if (State.ContainsKey("PanoramaSelectedItem"))
        var selIndex = (int)State["PanoramaSelectedItem"];
        mainPanorama.DefaultItem = mainPanorama.Items[selIndex];

Here’s the net result:

WorkingBefore AfterFixed

As you can see (left is before windows key, and right is after resuming), the presentation is slightly different, but we do end up on the same page. It’s a livable solution I think  (at least for now until they realize that they forgot about this possibility and fix it in the next rev).

BTW, this post is in response to Jeff Wilcox’ Intro to the Panorama and Pivot Controls.


Saturday, October 16, 2010 3:13:48 PM
Mark Drupal

re: WP7 Tip: Setting the Panorama Page After Tombstoning

Have a look here: http://blogs.ugidotnet.org/corrado/archive/2010/09/27/smartpanorama-a-panorama-control-extension.aspx

Comments are closed on this post.
Site Map | Printable View | © 2008 - 2015 Intradynamics | Powered by mojoPortal | HTML 5 | CSS | Design by mitchinson