Table of Contents

Class Page

Namespace
Icy.UI.Controls
Assembly
IcyUI.dll

A ContentControl that a Frame can navigate to.

public class Page : ContentControl, INotifyPropertyChanging, IBindingTarget, INotifyPropertyChanged, INotifyFocusChanged, IContainerLayout
Inheritance
Page
Implements
Inherited Members
Extension Methods

Remarks

A page is an ordinary ContentControl - its Content is the page's actual UI, settable via markup like any other content property. What makes it navigable is INavigationService knowing to construct/load it and swap it into a Frame's Content, calling OnNavigatedTo(object, NavigationEventArgs)/OnNavigatedFrom(object, NavigationEventArgs) as it does.

A markup file's root can be a <Page x:Class="MyApp.HomePage"> like any other element with an x:Class - see Class. Loading a page through Navigate(string) uses this the same way any other markup load does; there is no separate page-loading mechanism.

Properties

IsInitialized

Gets a value indicating whether Initialize() has already run for this instance.

public bool IsInitialized { get; }

Property Value

bool

KeepAlive

Gets or sets a value indicating whether a NavigationService should keep this page's instance in its back/forward history after navigating away from it.

public bool KeepAlive { get; set; }

Property Value

bool

Remarks

A page that isn't kept alive is dropped from history as soon as its NavigationService leaves it - navigating back past it isn't possible, and returning to the same logical page requires a fresh Navigate(string) call. Keep it alive when the page holds state (scroll position, unsaved form input, a view-model) worth returning to unchanged.

Path

Gets or sets the path this page was loaded from, if it was loaded through Navigate(string).

[Browsable(false)]
public string? Path { get; set; }

Property Value

string

Methods

Initialize()

Runs this page's one-time setup, if it hasn't already.

public void Initialize()

Remarks

Called by NavigationService on every navigation to this page; the IsInitialized guard is what makes repeated calls (e.g. after a KeepAlive return trip) a no-op. Override OnInitialize() for the actual one-time work rather than this method, so the guard can't accidentally be bypassed by a subclass forgetting to check it.

OnInitialize()

This page's one-time setup. Runs once per instance, the first time Initialize() is called.

protected virtual void OnInitialize()

OnNavigatedFrom(object, NavigationEventArgs)

Called before a NavigationService navigates away from this page.

protected virtual void OnNavigatedFrom(object sender, NavigationEventArgs args)

Parameters

sender object

The INavigationService performing the navigation.

args NavigationEventArgs

The pages involved in the navigation.

OnNavigatedTo(object, NavigationEventArgs)

Called after a NavigationService navigates to this page.

protected virtual void OnNavigatedTo(object sender, NavigationEventArgs args)

Parameters

sender object

The INavigationService that performed the navigation.

args NavigationEventArgs

The pages involved in the navigation.

Prepare()

Called every time a NavigationService makes this page current, including repeat visits to a KeepAlive page - unlike Initialize(), there is no once-only guard here.

public virtual void Prepare()