Navigation Fundamentals: Frame and Page
UWP apps navigate between screens using a Frame control that hosts Page instances, much like a web browser hosts pages within a history stack. Calling Frame.Navigate(typeof(TargetPage)) pushes a new page onto the Frame's back stack and displays it, while Frame.GoBack() pops that stack and returns to the previous page, giving UWP apps a built-in, consistent forward/back navigation model without any custom routing code.
Cricket analogy: Like a Test match's over-by-over history sheet — each over (Page) is recorded in sequence in a scorebook (the Frame's back stack), and you can always flip back to review a previous over.
Passing Parameters and Handling the Back Button
Frame.Navigate accepts an optional parameter object, retrievable in the destination page by overriding OnNavigatedTo(NavigationEventArgs e) and reading e.Parameter; this is the standard way to tell a detail page which record to load, typically passing a lightweight ID or small DTO rather than a large object graph. For the back button itself, apps subscribe to SystemNavigationManager.GetForCurrentView().BackRequested and call Frame.GoBack() when Frame.CanGoBack is true, unifying the hardware back button, the software back button, and any custom in-app back UI into one code path.
Cricket analogy: Like handing the incoming batter a note about the bowler's field placement, a navigation parameter, as they walk out, information they read the moment they arrive at the crease (OnNavigatedTo).
// Navigate with a parameter
Frame.Navigate(typeof(OrderDetailPage), selectedOrder.Id);
// In OrderDetailPage.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var orderId = (int)e.Parameter;
ViewModel.LoadOrder(orderId);
}
// Handle the hardware/software back button
SystemNavigationManager.GetForCurrentView().BackRequested += (s, args) =>
{
if (Frame.CanGoBack)
{
Frame.GoBack();
args.Handled = true;
}
};Set a Page's NavigationCacheMode to Required or Enabled to keep its instance (and scroll position/state) alive in the Frame's cache when navigating away and back, avoiding an expensive full reconstruction of the page each time the user returns to it.
NavigationView for Master Navigation UI
For apps with several top-level sections, NavigationView provides a standard hamburger-menu-and-pane navigation shell: MenuItems define the app's sections, and PaneDisplayMode controls how the pane presents itself — a fully expanded pane with icons and labels, a compact icon-only rail, a minimal overlay triggered by a hamburger button, or a top-aligned bar — automatically switching presentation based on available window width so the same NavigationView looks right on a phone or a wide desktop window.
Cricket analogy: Like a stadium's master scoreboard hub showing a match-selection menu, letting fans switch between simultaneously running games via a collapsible list.
Deep Linking and URI Activation
UWP apps can register a custom URI scheme and handle protocol activation by overriding OnActivated(IActivatedEventArgs e) in App.xaml.cs, inspecting the incoming Uri to decide which page to navigate the root Frame to directly — even on a cold start where the app wasn't already running. This is how a notification, another app, or the shell can launch a UWP app straight into a specific piece of content instead of always landing on the default start page.
Cricket analogy: Like a fan clicking a direct link to 'over 42 highlights' in a match app and landing exactly there, rather than starting from the match's beginning.
If you navigate to the same page repeatedly without checking Frame.BackStack for an existing entry, or without managing NavigationTransitionInfo appropriately, the back stack can grow unbounded, letting users press Back many times through duplicate entries instead of landing where they expect.
- The Frame control hosts Page instances and maintains a back stack, providing Navigate/GoBack navigation similar to a web browser history.
- Frame.Navigate(typeof(TargetPage), parameter) passes a parameter object retrieved in the target page's OnNavigatedTo override.
- SystemNavigationManager.BackRequested lets an app respond to the hardware/software back button and integrate it with Frame.GoBack.
- NavigationCacheMode controls whether a page instance is cached in the Frame, preserving state without a full reconstruction.
- NavigationView provides a standard pane-based navigation shell with hamburger, compact, and expanded display modes.
- Protocol/URI activation (OnActivated) enables deep linking directly into a specific page or state rather than the app's default start page.
Practice what you learned
1. Where should a UWP page typically read a navigation parameter passed via Frame.Navigate?
2. What does NavigationCacheMode.Required do?
3. Which control provides a standard hamburger/pane-based navigation shell in UWP?
4. What UWP mechanism enables an app to be launched directly to a specific page via a custom URI?
5. What is a consequence of not managing the Frame's back stack when repeatedly navigating to the same page?
Was this page helpful?
You May Also Like
UWP Controls and Layout
How UWP's layout panels and built-in controls work together, including Grid sizing, RelativePanel, and ListView virtualization.
Adaptive Design in UWP
Techniques for building UWP UI that adapts across phone, tablet, desktop, and Xbox using VisualStateManager, AdaptiveTrigger, and RelativePanel.
UWP Styles and Templates
How Styles, ResourceDictionaries, and ControlTemplates let you centralize and theme a UWP app's visual appearance.
Related Reading
Related Study Notes in Microsoft Technologies
Browse all study notesWindows Batch Scripting Study Notes
Batch · 30 topics
Microsoft TechnologiesMFC (Microsoft Foundation Classes) Study Notes
C++ · 30 topics
Microsoft TechnologiesSilverlight Study Notes
.NET · 30 topics
Microsoft TechnologiesXAML Study Notes
.NET · 30 topics
Microsoft TechnologiesWPF (Windows Presentation Foundation) Study Notes
.NET · 30 topics
Microsoft TechnologiesMVVM Design Pattern Study Notes
.NET · 30 topics