Create a page
A page is a view with a job: show a notebook, edit a setting, or describe a route. Start with a container that owns its content and state, then let navigation add the title and Back action.
Keep the content focused
The notebook in this example is a VerticalStack. It owns a count, a label, and a button. It does not know how the app reached it or where Back will go.
using Xui.Core.UI;
using Xui.ToolKit.UI.Branding;
using Xui.ToolKit.UI.Design;
using Xui.ToolKit.UI.Navigation;
using Xui.ToolKit.UI.Widgets;
public sealed class PagesExample : Border
{
public PagesExample()
{
Content = new DesignSystemView(new NavigationShell("Field notes", new XuiLogoView(), [new("Notebook", "Notebook", () => new NotebookPage()), new("About", "About", () => new Label { Text = "A place for small discoveries.", FontFamily = "Inter", FontSize = 16, Margin = 24 })], desktop: false));
}
private sealed class NotebookPage : VerticalStack
{
public NotebookPage()
{
Margin = 24;
var count = 0;
var note = new Label
{
Text = "No notes yet.",
FontFamily = "Inter",
FontSize = 18,
Margin = 8
};
Add(note);
Add(new Button { Text = "Add a note", Margin = 8, Clicked = () => note.Text = $"Notes: {++count}" });
}
}
}
Open Notebook and add a note. The body updates in place. Return to the home page and open Notebook again: this mobile shell creates a new page, so the count starts over. That is a deliberate lifetime decision, not a rendering failure.
Let NavigationPage own the heading
NavigationPage wraps content with a centered title and optional Back button. NavigationShell creates this wrapper for its destinations. Do not add a duplicate title bar to every content view unless the page intentionally needs a different hierarchy.
When constructing a page outside the shell, this expression shows the composition:
new Xui.ToolKit.UI.Navigation.NavigationPage(
"Notebook",
new Xui.Core.UI.Label { Text = "No notes yet.", Margin = 24 });
Pass a third Action argument when the wrapper should show Back. The action belongs to the navigation owner; the content should not guess which parent to remove itself from.
Choose the container for the content
Use VerticalStack for a short sequence of content-sized rows. Use a Grid or custom container when a page must reserve a header and give the rest of the window to a list. A stack measures along its stacking axis with unbounded space; putting a viewport-filling child inside it can defeat the intended sizing.
For longer content, wrap the stack in ScrollView and give that scroll view a bounded viewport. Avoid making a page's entire tree larger than the window and hoping that drawing outside the frame will create scrolling.
Keep identifiers stable for tests, return fresh views from factories, and preserve data outside a page when it must survive page recreation. Continue with Page state and lifetime.