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 MEF 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.
Export Information
Each subpage must provide Source property that returns IExportInfo, which identifies the module where the subpage is defined. This is used by the MEF container for dependency resolution.
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 (e.g., SettingsAppearanceViewModel):
To make the subpage discoverable by MEF, create a custom export attribute (e.g., ExportSettingsAttribute):
API
ITreeSubpage
Represents a subpage that can be displayed in a tree-based page structure. Extends IRoutable and IExportable to provide routing and MEF export 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.
Property | Type | Description |
|---|---|---|
|
| Gets export metadata (abstract, must override). |
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.