Bojan Zloporubovic Bojan Zloporubovic - 9 months ago 27
C# Question

Windows phone save form

I'm developing some app for Windows phone 8.1, and I have this problem:

Have 1 form with some checkbox, radio buttons and some text fields. When I fill it up, and move to next form with:

Frame.Navigate(typeof(SOME_FORM));


and I have some things to do, and want to come back to 1st form, it's all cleared. How to remember what i fill up on 1st form, when i come back from 2nd?

And I add all controls programmatically, so I can't save it in static variable.
Any help?

Answer Source

In your first page set property NavigationCacheMode to Required in XAML

NavigationCacheMode="Required"

or in code behind

this.NavigationCacheMode = NavigationCacheMode.Required;

But the question is: when do you add controls to page? if you add control in OnNavigatedTo you should check NavigationMode and don't reload page on back navigation

protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        if (e.NavigationMode == NavigationMode.Back)
        {
//do nothing - filled controls already there
            return;
        }
        //add controls
    }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download