Tree Subpage
Overview
TreeSubpage is an abstract base class for content pages displayed within a TreePageViewModel.
It extends ViewModel and implements the ITreeSubpage interface.
TreeSubpage serves as the detail view that appears on the right side when a user selects a node in the tree menu. It includes its own menu system.
Core Components
Menu System
Each subpage has its own Menu collection and MenuView tree structure. This allows subpages to have their own toolbar or contextual menu items.
The menu items are automatically disposed when the subpage is disposed, and they inherit the routing parent from the subpage itself.
Generic Context
TreeSubpage<TContext> is a generic variant that receives an ITreeSubPageContext<TContext> through its constructor. The context carries both the navigation Args — forwarded to the base TreeSubpage — and the Context object itself, which is typically the parent page that hosts the subpage. The base class does not store or expose Context; a derived class that needs it after construction must retain it explicitly.
Example
A typical usage pattern involves creating a subpage interface, a base implementation, and then concrete subpages.
First, create an interface for your tree subpage (e.g., ISettingsSubPage). The context type is bound on the base class, not on the interface:
Next, implement a base class (e.g., SettingsSubPage):
Now create a concrete subpage view model. Simply inherit from the base class created above and pass the context through:
Each subpage needs a tree menu node — this is what appears in the left-hand tree. Create a class that inherits from TreePageMenuItem:
Finally, register the subpage, its view, and the tree menu node. The settings builder wraps all three registrations into one call:
API
ITreeSubpage
Represents a subpage that can be displayed in a tree-based page structure. Extends IViewModel to provide identity, parent/child routing, undo and layout support.
Property | Type | Description |
|---|---|---|
|
| Gets the tree structure for the subpage's menu. |
|
| Gets the collection of menu items associated with the page. |
ITreeSubPageContext<TContext>
Carries what a subpage receives at construction. TreeSubPageContext<TContext> is the standard implementation; NullTreeSubPageContext<TContext> is used at design time.
Property | Type | Description |
|---|---|---|
|
| Navigation arguments, forwarded to the base |
|
| The page that hosts the subpage. |
TreeSubpage: ITreeSubpage
Base implementation of ITreeSubpage. Provides menu management and proper disposal of resources.
Constructor | Description |
|---|---|
| Protected. Creates the subpage and its menu tree. |
Method | Return Type | Description |
|---|---|---|
|
| Returns the menu items as child view models. |
|
| Releases resources and clears the menu. |
TreeSubpage<TContext>: TreeSubpage
Generic base implementation that binds a page context type. It adds no members of its own — it forwards context.Args to the base constructor. Constrained to where TContext : class, IPage.
Constructor | Description |
|---|---|
| Protected. Forwards |