Class ComposableTreeView
Implements a tree view whose items are composed by a CompositionContainer.
Inheritance
Implements
Namespace: Sartorius.SAF.Presentation.Controls
Assembly: Sartorius.SAF.Presentation.Controls.dll
Syntax
public class ComposableTreeView : TreeView, IAnimatable, ISupportInitialize, IFrameworkInputElement, IInputElement, IQueryAmbient, IContainItemStorage, IAddChild
Examples
This example and the following examples illustrate how to use the ComposableTreeView control to compose a TreeView that contains various setting sections (e.g. user settings, system settings, etc.).
As a first step, an interface must be defined that derives from IComposableTreeViewItem in order to have a unique compose identifier for that specific tree view.
Then, one or more classes must be created which implement the defined interface. Each interface implementation represents one TreeViewItem of the ComposableTreeView.
Each time the user clicks on a TreeViewItem, the OnActivate() method is called, which (in this example) then calls the RequestNavigate method of the IRegionManager and loads the proper View (and ViewModel) in the given region.
The implementations shall derive from ObservableObject so that the IComposableTreeViewItem notifies the user interface about property changes. The implementation shall also import the underlying ViewModel and subscribe to INotifyErrorsChanged. This way, the TreeViewItem can display an error indication.
Finally, the ComposableTreeView control must be added to the user interface.
It is important that the ComposableTreeViewItemType matches the unique compose identifier. To get the exported values of the IComposableTreeViewItem implementations, the ComposableTreeView uses Container as default value of the CompositionContainer.
<SAF:ComposableTreeView ComposableTreeViewItemType="{x:Type local:ISettingsTreeViewItem}"
SelectionMode="FirstChild" />
Constructors
View SourceComposableTreeView()
Creates a new instance of the ComposableTreeView class.
Declaration
public ComposableTreeView()
Fields
View SourceAutoGenerationModeProperty
Defines the DependencyProperty of the AutoGenerationMode property.
Declaration
public static readonly DependencyProperty AutoGenerationModeProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
ComposableTreeViewItemTypeProperty
Defines the DependencyProperty of the ComposableTreeViewItemType property.
Declaration
public static readonly DependencyProperty ComposableTreeViewItemTypeProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
CompositionContainerProperty
Defines the DependencyProperty of the CompositionContainer property.
Declaration
public static readonly DependencyProperty CompositionContainerProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
SelectedItemIdProperty
Defines the DependencyProperty of the SelectedItemId property.
Declaration
public static readonly DependencyProperty SelectedItemIdProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
SelectionModeProperty
Defines the DependencyProperty of the SelectionMode property.
Declaration
public static readonly DependencyProperty SelectionModeProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
Properties
View SourceAutoGenerationMode
Gets or sets the TreeViewAutoGenerationMode.
Declaration
public TreeViewAutoGenerationMode AutoGenerationMode { get; set; }
Property Value
| Type | Description |
|---|---|
| TreeViewAutoGenerationMode |
ComposableTreeViewItemType
Gets or sets the Type that is used to compose the tree view items.
Declaration
public Type ComposableTreeViewItemType { get; set; }
Property Value
| Type | Description |
|---|---|
| Type |
CompositionContainer
Gets or sets the CompositionContainer that is used as the composition source.
Declaration
public CompositionContainer CompositionContainer { get; set; }
Property Value
| Type | Description |
|---|---|
| CompositionContainer |
SelectedItemId
Gets or sets the id of the SelectedItem.
Declaration
public Guid? SelectedItemId { get; set; }
Property Value
| Type | Description |
|---|---|
| Guid? |
Examples
The following example shows how to set the default selected item. In this example the default will be overwritten when the ComposableTreeViewSettingBehavior loads the previously saved selected item. So the default will only be used on the first start of the application.
View Source
SelectionMode
Gets or sets the TreeViewSelectionMode.
Declaration
public TreeViewSelectionMode SelectionMode { get; set; }
Property Value
| Type | Description |
|---|---|
| TreeViewSelectionMode |
Methods
View SourceGetContainerForItemOverride()
Creates a ComposableTreeViewItemContainer to use to display content.
Declaration
protected override DependencyObject GetContainerForItemOverride()
Returns
| Type | Description |
|---|---|
| DependencyObject | A new ComposableTreeViewItemContainer to use as a container for content. |
Overrides
View SourceOnApplyTemplate()
When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().
Declaration
public override void OnApplyTemplate()
Overrides
View SourceOnGotFocus(RoutedEventArgs)
Raises the GotFocus routed event.
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| RoutedEventArgs | e | The data for the event. |
Overrides
View SourceOnSelectedItemChanged(RoutedPropertyChangedEventArgs<object>)
Raises the TreeView.SelectedItemChanged event when the TreeView.SelectedItem property value changes.
Declaration
[SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Parameter e is never null")]
protected override void OnSelectedItemChanged(RoutedPropertyChangedEventArgs<object> e)
Parameters
| Type | Name | Description |
|---|---|---|
| RoutedPropertyChangedEventArgs<object> | e | Provides the item that was previously selected and the item that is currently selected for the System.Windows.Controls.TreeView.SelectedItemChanged event |
Overrides
View SourceSelectItem(Guid)
Selects the HierarchicalComposableTreeViewItem with the given id.
Declaration
public virtual void SelectItem(Guid id)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | id | The id of the HierarchicalComposableTreeViewItem. |
SelectItem(object)
Selects the given item within the tree view. If the item is collapsed, it is expanded.
Declaration
public virtual void SelectItem(object item)
Parameters
| Type | Name | Description |
|---|---|---|
| object | item | The tree view item that should be selected. |