Conductor: Pivot Restore from Tombstone

Topics: Bugs
Sep 13, 2011 at 11:00 AM

Hi Guys,

What is the correct way to restore a Conductor from Tombstone. More specifically,

Scenario

1. I am using a Conductor as my MainPageViewModel (Pivot control) and have created a MainPageViewModelStorage to manage the storage of the ActiveItemIndex.

2. I then navigate to a page after clicking a List Item.

3.  I tombstone the application (using emulator window button).

4.  I restore the application using the back button.

5. I get an Argument Out of Exception (Index) because the Items in the conductor (PivotPages) have not yet been created. The conductor constructor is called but I have determined that the OnInitialize is not called.

Regards,

Tarek

Sep 15, 2011 at 3:25 PM

your MainPageViewModelStorage derives from MainPageViewModel but its not storing correctly the activeitemindex....  Is the below snippent close to what you have?  I assume that the index is something you created to store the index of the pivot?

 

public class MainpageViewModelStorage : StorageHandler<MainPageViewModel>
{

     public override void Configure(){

             Id(x=>x.DisplayName);

             Property(x=>x.Items).InPhoneSettings().RestoreAfterViewLoad(); 
             Property(x=>x.ActiveItem).InPhoneSettings().RestoreAfterViewLoad();
             Property(x => x.ActiveItemIndex).InPhoneSettings().RestoreAfterViewLoad();
     }

}

Sep 16, 2011 at 7:52 AM

Hi Mvermef,

Actually, I only have the following - 

this.ActiveItemIndex().InPhoneState().RestoreAfterActivation();

Regards,

Tarek

Sep 17, 2011 at 12:55 AM
Edited Sep 17, 2011 at 12:56 AM

it needs to be in the format I posted as well as store everything you think is necessary for the page / pivot etc to store and restore accordingly.

Your getting the error cause the Items collection is probably empty with the Conductor.