Saving and restoring state: Accessing MainPage from App RRS feed

  • Question

  • I have a Windows 8 app in which I want to save & restore the state. I am using the Blank Page template. From what I understand, state should be stored during the Suspending event of the App class. This is fine, except that I don't have access to most of the data & controls for which I need to save the state. I have managed to figure out that
    CType(CType(Window.Current.Content, Frame).Content, MainPage)
    gives a reference to the page, but most of the properties & controls are not accessible from here because it is a different class. I thought about making several functions in MainPage that return the desired properties/values, but that seems somewhat inefficient, not to mention they would need updated every time I modified my code. Where & when should I be saving my state so that I have access to the values I need to save? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Wednesday, March 4, 2015 8:15 PM