Search code examples
c#.netuwpwin-universal-appwindows-10-universal

UWP - How to save frame backstack and current page?


Hi I have this hierarchy

App (RootFrame)

  • Login Page
  • Main Shell (InnerFrame)
    • List Page with entities 1
    • List Page with entities 2
  • Detail Page for entity 1 (InnerFrame2)
    • subpage 1-1
    • subpage 1-2
  • Detail Page for entity 2 (InnerFrame3)
    • subpage 2-1
    • subpage 2-1

And I want to handle Back button correctly. Navigating between pages in inner frames is ok, but when I go for example from "List Page with entities 2" to "Detail page for entity 2" and then back, MainShell i recreated and forgets the InnerFrames BackStack and opened Page(should be "List Page with entities 2")

Is there any elegant way to handle this? for example save InnerFrames history and current page when navigatedFrom at MainShell happens?


Solution

  • I found what I needed. There are SetNavigationState(string) and GetNavigationState() methods on Frame object. Thanks anyway