Table of Contents

Class NavigationService

Namespace
Icy.Navigation
Assembly
IcyUI.dll

The default INavigationService - every Frame owns exactly one, created for it in its constructor.

public sealed class NavigationService : INavigationService
Inheritance
NavigationService
Implements
Inherited Members
Extension Methods

Remarks

Navigate(string) resolves path against the owning Frame's configuration (DefaultAssetContext), the same asset pipeline any other .xml markup file loads through - see MarkupImporter. IsAvailable(string?) is what makes a missing page return null instead of throwing: everything else the loader can fail on (malformed markup, a root that isn't a Page) is a genuine error, not a "not found".

Back/forward history is two stacks of Page instances. Navigating away from a page only pushes it onto the relevant stack when KeepAlive is set - see its remarks for why. A fresh forward-navigation (Navigate(string) or NavigateTo(Page)) always clears the forward history, the same way a browser discards forward history once you navigate somewhere new instead of following "next" again.

Constructors

NavigationService(Frame)

The default INavigationService - every Frame owns exactly one, created for it in its constructor.

public NavigationService(Frame frame)

Parameters

frame Frame

The frame this service navigates.

Remarks

Navigate(string) resolves path against the owning Frame's configuration (DefaultAssetContext), the same asset pipeline any other .xml markup file loads through - see MarkupImporter. IsAvailable(string?) is what makes a missing page return null instead of throwing: everything else the loader can fail on (malformed markup, a root that isn't a Page) is a genuine error, not a "not found".

Back/forward history is two stacks of Page instances. Navigating away from a page only pushes it onto the relevant stack when KeepAlive is set - see its remarks for why. A fresh forward-navigation (Navigate(string) or NavigateTo(Page)) always clears the forward history, the same way a browser discards forward history once you navigate somewhere new instead of following "next" again.

Properties

CurrentPage

Gets the page currently hosted by this service's Frame, or null if none has been navigated to yet.

public Page? CurrentPage { get; }

Property Value

Page

Methods

Clear()

Clears the back/forward history and the frame's current content.

public void Clear()

Navigate(string)

Loads the page at path through the asset pipeline and navigates to it.

public Page? Navigate(string path)

Parameters

path string

A path resolved against the owning Frame's configuration's default asset context.

Returns

Page

The page navigated to, or null if path doesn't exist.

NavigateTo(Page)

Navigates to an already-constructed page instance.

public Page NavigateTo(Page page)

Parameters

page Page

The page to navigate to.

Returns

Page

page, or the frame's unchanged CurrentPage if a Navigating handler canceled the navigation.

TryNavigateBack()

Navigates to the previous page in the back history, if any.

public Page? TryNavigateBack()

Returns

Page

The page navigated to, or null if there is no back history, or a handler canceled it.

TryNavigateNext()

Navigates to the next page in the forward history, if any.

public Page? TryNavigateNext()

Returns

Page

The page navigated to, or null if there is no forward history, or a handler canceled it.

Events

Navigating

Occurs before a navigation takes effect. Setting Cancel leaves the frame showing whatever it already was.

public event EventHandler<NavigationEventArgs>? Navigating

Event Type

EventHandler<NavigationEventArgs>