Page Navigation in 3.10.0

In the 3.10.0 release several new page navigation methods were added. I thought I’d say a few words about all of the methods, both new & old.

PushPage / PopPage

The Home Remote app manages a navigation stack for you. When you call PushPage it pushes your page onto the navigation stack and brings it into view. You can navigate back to your previous page by using the system’s Back button or by calling PopPage. PopPage removes the current page from the navigation stack. The system’s Back button triggers the PopPage method internally so they both accomplish the same thing.

PushPage & PopPage have been around for a few years now & they’re not going away. They are meant to be used in conjunction with the new methods.

OpenPage / ClosePage

The latest release introduces the term “Opened” page. When you call OpenPage we will flag the page you’ve provided as “Opened”. With this we can help provide better management of the navigation stack for you.

Here are some of the things it does:

  • If you call OpenPage while the page is already “Opened”, it’ll simply ignore the request because it doesn’t have to do anything.

  • If you call OpenPage while a different page is “Opened”, it will automatically close that previous page first & then open your new page. This means that at any point in time, only 1 page will ever be flagged as “Open”.

  • If you call PushPage while a page is “Opened”, the new page will automatically be linked to the “Opened” page. Consider you called OpenPage(“MediaPlayer.xaml”) & once that page appeared you clicked on a button that called PushPage(“SoundModes.xaml”). “MediaPlayer.xaml” would still be the “Opened” page even though “SoundModes.xaml” is currently displayed on the screen, but they will be linked together. When you call ClosePage it will remove both of those pages from the navigation stack for you. This is a perfect example of when you would use a combination of both OpenPage & PushPage. You wouldn’t want to call OpenPage on “SoundModes.xaml” because you’d still like to retain the ability to go back to “MediaPlayer.xaml”.

ClosePage can include an optional Page parameter. When a Page is supplied it will only execute if the name matches that of the current “Opened” page. When you leave the parameters blank, it’ll close the current “Opened” page, if there is one.

As you can see, these methods are very similar to PushPage & PopPage. They are meant to help prevent misuse of the navigation stack. These will be especially useful when developing Scenes that perform automated page browsing.

OpenDeviceDetails / CloseDeviceDetails

These methods are identical to OpenPage / ClosePage. The only difference is that you’ll supply the Device Name instead of the XAML file name. Internally it’ll look up the DetailsTemplate you’ve assigned to the device & then supply that value to either OpenPage or ClosePage.

GoToPage

Clears the navigation stack & replaces the root page with the XAML file you supply.

GoToGroup

Clears the navigation stack & replaces the root page with the automatically generated group page. The parameter you supply is the name of the GroupCollection.

PopToRoot

Removes all but the root page from the navigation stack.

1 Like