Tree Subpage
Overview
TreeSubpage is an abstract base class for content pages displayed within a TreePageViewModel.
It extends RoutableViewModel 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 and can be extended through the DI container.
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 a context object during initialization via the Init method. This context is typically the parent page that hosts the subpage, allowing the subpage to access shared data or services.
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):
Next, implement a base class (e.g., SettingsSubPage):
Now create a concrete subpage view model. Simply inherit from the base class created above:
Each subpage needs a tree menu node — this is what appears in the left-hand tree. Create a class that inherits from TreePage:
Finally, register the subpage, its view, and the tree menu node:
API
ITreeSubpage
Represents a subpage that can be displayed in a tree-based page structure. Extends IRoutable to provide routing capabilities.
Property | Type | Description |
|---|---|---|
|
| Gets the tree structure for the subpage's menu. |
|
| Gets the collection of menu items associated with the page. |
ITreeSubpage<TContext>
Generic variant of ITreeSubpage that receives a context during initialization.
Method | Return Type | Description |
|---|---|---|
|
| Initializes the subpage with the specified context object. |
TreeSubpage: ITreeSubpage
Base implementation of ITreeSubpage. Provides menu management and proper disposal of resources.
Method | Return Type | Description |
|---|---|---|
|
| Returns the menu items as child routable elements. |
|
| Releases resources and clears the menu. |
TreeSubpage<TContext>: ITreeSubpage<TContext>
Generic base implementation that adds context initialization support.