In This Article

TreeListBoxItemAdapter Class

An adapter that can provide an item's hierarchy and visual state data for usage in a TreeListBox.

public class TreeListBoxItemAdapter
Inheritance:
object object
Derived:
PropertyGridItemAdapter ShellObjectItemAdapter

Constructors

TreeListBoxItemAdapter()

Initializes an instance of the class.

public TreeListBoxItemAdapter()

Properties

ChildrenBinding

Gets or sets a Binding that can be used to retrieve an IEnumerable of child items.

public Binding ChildrenBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetChildren(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetChildren(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetChildren(TreeListBox, object) method instead.

ChildrenPath

Gets or sets the resolved item property name for which to monitor INotifyPropertyChanged events related to child items.

public string ChildrenPath { get; set; }

Property Value

string:

The name of the property to monitor.

ChildrenQueryModeDefault

Gets or sets a default GetChildrenQueryMode(TreeListBox, object) return value for designating when children are queried.

public TreeItemChildrenQueryMode ChildrenQueryModeDefault { get; set; }

Property Value

TreeItemChildrenQueryMode:

A TreeItemChildrenQueryMode indicating the children query mode. The default value is OnDisplay.

Remarks

This value is returned by GetChildrenQueryMode(TreeListBox, object).

DefaultActionCommandBinding

Gets or sets a Binding that can retrieve the default action command.

public Binding DefaultActionCommandBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetDefaultActionCommand(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetDefaultActionCommand(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetDefaultActionCommand(TreeListBox, object) method instead.

ExpandabilityDefault

Gets or sets a default GetExpandability(TreeListBox, object, int) return value for designating item expandability.

public TreeItemExpandability ExpandabilityDefault { get; set; }

Property Value

TreeItemExpandability:

A TreeItemExpandability indicating the expandability. The default value is Auto.

Remarks

This value is returned by GetExpandability(TreeListBox, object, int).

IsDraggableBinding

Gets or sets a Binding that determines whether an item is draggable.

public Binding IsDraggableBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetIsDraggable(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetIsDraggable(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetIsDraggable(TreeListBox, object) method instead.

IsEditableBinding

Gets or sets a Binding that determines whether an item is editable.

public Binding IsEditableBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetIsEditable(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetIsEditable(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetIsEditable(TreeListBox, object) method instead.

IsEditableDefault

Gets or sets a default GetIsEditable(TreeListBox, object) return value as to whether all items should be editable.

public bool IsEditableDefault { get; set; }

Property Value

bool:

true if all items should be editable; otherwise, false. The default value is false.

Remarks

This value is returned by GetIsEditable(TreeListBox, object) if no IsEditableBinding is set. Set this property to true to allow all items to be editable. Note that an IsEditableBinding value will override it.

IsEditingBinding

Gets or sets a Binding that determines whether an item is currently being edited.

public Binding IsEditingBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetIsEditing(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetIsEditing(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetIsEditing(TreeListBox, object) method instead.

IsEditingPath

Gets or sets the item property name for which to monitor INotifyPropertyChanged events related to editing states.

public string IsEditingPath { get; set; }

Property Value

string:

The name of the property to monitor.

IsExpandedBinding

Gets or sets a Binding that determines whether an item should be expanded.

public Binding IsExpandedBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetIsExpanded(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetIsExpanded(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetIsExpanded(TreeListBox, object) method instead.

IsExpandedDefault

Gets or sets a default GetIsExpanded(TreeListBox, object) return value as to whether all items should be initially expanded.

public bool IsExpandedDefault { get; set; }

Property Value

bool:

true if all items should be initially expanded; otherwise, false. The default value is false.

Remarks

This value is returned by GetIsExpanded(TreeListBox, object) if no IsExpandedBinding is set. Set this property to true to always fully expand a tree. Note that an IsExpandedBinding value will override it.

IsExpandedPath

Gets or sets the item property name for which to monitor INotifyPropertyChanged events related to expansion states.

public string IsExpandedPath { get; set; }

Property Value

string:

The name of the property to monitor.

IsLoadingBinding

Gets or sets a Binding that determines whether an item is currently loading children asynchronously.

public Binding IsLoadingBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetIsLoading(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetIsLoading(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetIsLoading(TreeListBox, object) method instead.

IsLoadingPath

Gets or sets the item property name for which to monitor INotifyPropertyChanged events related to async children loading states.

public string IsLoadingPath { get; set; }

Property Value

string:

The name of the property to monitor.

IsSelectableBinding

Gets or sets a Binding that determines whether an item is capable of being selected.

public Binding IsSelectableBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetIsSelectable(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetIsSelectable(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetIsSelectable(TreeListBox, object) method instead.

IsSelectablePath

Gets or sets the item property name for which to monitor INotifyPropertyChanged events related to selection capabilities.

public string IsSelectablePath { get; set; }

Property Value

string:

The name of the property to monitor.

IsSelectedBinding

Gets or sets a Binding that determines whether an item should be selected.

public Binding IsSelectedBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetIsSelected(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetIsSelected(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetIsSelected(TreeListBox, object) method instead.

IsSelectedPath

Gets or sets the item property name for which to monitor INotifyPropertyChanged events related to selection states.

public string IsSelectedPath { get; set; }

Property Value

string:

The name of the property to monitor.

PathBinding

Gets or sets a Binding that can retrieve the path of an item, relative to its parent.

public Binding PathBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetPath(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetPath(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetPath(TreeListBox, object) method instead.

SearchTextBinding

Gets or sets a Binding that can retrieve the search text of an item.

public Binding SearchTextBinding { get; set; }

Property Value

Binding:

The Binding to use.

Remarks

When this property is set, it will be used within the default implementation of the GetSearchText(TreeListBox, object) method. Please note that bindings take longer to execute than a code-based override of the GetSearchText(TreeListBox, object) method. If you encounter any performance issues when using this binding, override the GetSearchText(TreeListBox, object) method instead.

TopLevelExpandabilityDefault

Gets or sets a default GetExpandability(TreeListBox, object, int) return value for designating only top-level item expandability.

public TreeItemExpandability TopLevelExpandabilityDefault { get; set; }

Property Value

TreeItemExpandability:

A TreeItemExpandability indicating the expandability. The default value is Auto, meaning fall back to the ExpandabilityDefault value.

Remarks

This value is returned by GetExpandability(TreeListBox, object, int).

Methods

CanHaveChildren(TreeListBox, object)

Returns whether the specified item is capable of having child items.

public virtual bool CanHaveChildren(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

bool:

true if the specified item is capable of having child items; otherwise, false.

Remarks

The default implementation of this method returns true. This method should only return false if an item is not capable of having child items and is always a 'leaf' node in the tree. It should not return false if the item can have child items, but doesn't at the current time.

Optimizations are in place to not call GetChildren(TreeListBox, object) when this method returns true. This method should be overridden if OnExpansion is used and certain items are known to be 'leaf' nodes.

CreateVirtualPlaceholder(TreeListBox, object, int)

Creates a virtual placeholder for an item's child at the specified index, when data virtualization is enabled.

public virtual ITreeItemVirtualPlaceholder CreateVirtualPlaceholder(TreeListBox ownerControl, object parentItem, int index)
Parameter Type Description
ownerControl TreeListBox

The owner control.

parentItem object

The parent item.

index int

The index of the child.

Returns

ITreeItemVirtualPlaceholder:

The ITreeItemVirtualPlaceholder that was created.

Filter(TreeListBox, object)

Examines the specified item to see if meets active filter conditions.

public virtual DataFilterResult Filter(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

DataFilterResult:

A DataFilterResult that indicates the filter result.

Remarks

The default implementation of this method uses the DataFilter value to filter the item. If no data filter is available, the method returns Included.

GetAbsolutePath(TreeListBox, object)

Returns the item's absolute (rooted) string path, if known from the item itself.

public virtual string GetAbsolutePath(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

string:

The item's absolute (rooted) string path, if known.

Remarks

The absolute path can be used to improve performance when searching for an item in a large tree since it allows for a path-based search instead of an exhaustive breadth-first search through the tree. A null string should be returned for items that don't know their absolute path.

GetChildren(TreeListBox, object)

Returns an IEnumerable that will be used to provide child items for the specified parent item.

public virtual IEnumerable GetChildren(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

IEnumerable:

An IEnumerable that will be used to provide child items for the specified parent item.

Remarks

The ChildrenBinding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

GetChildrenQueryMode(TreeListBox, object)

Returns the children query mode of the specified item.

public virtual TreeItemChildrenQueryMode GetChildrenQueryMode(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

TreeItemChildrenQueryMode:

A TreeItemChildrenQueryMode indicating the children query mode.

Remarks

The default implementation of this method returns the ChildrenQueryModeDefault property value. That property can be set in XAML, or this method may be overridden for more complex logic.

GetDefaultActionCommand(TreeListBox, object)

Returns the default action command.

public virtual ICommand GetDefaultActionCommand(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

ICommand:

The ICommand to execute as a default action.

Remarks

The DefaultActionCommandBinding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

GetExpandability(TreeListBox, object, int)

Returns the expandability of the specified item.

public virtual TreeItemExpandability GetExpandability(TreeListBox ownerControl, object item, int depth)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

depth int

The item depth.

Returns

TreeItemExpandability:

A TreeItemExpandability indicating the expandability.

Remarks

The default implementation of this method examines the TopLevelExpandabilityDefault property if the item is top-level. If that property return Auto, or if the item isn't top-level, the ExpandabilityDefault property value is returned. Both properties can be set in XAML, or this method may be overridden for more complex logic.

GetIndentAmount(TreeListBox, object, int)

Returns the indent amount of the specified item.

public virtual double GetIndentAmount(TreeListBox ownerControl, object item, int depth)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

depth int

The item depth.

Returns

double:

The indent amount.

GetIsDraggable(TreeListBox, object)

Returns whether the specified item is draggable.

public virtual bool GetIsDraggable(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

bool:

true if the specified item is draggable; otherwise, false.

Remarks

The IsDraggableBinding binding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

GetIsEditable(TreeListBox, object)

Returns whether the specified item is editable.

public virtual bool GetIsEditable(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

bool:

true if the specified item is editable; otherwise, false.

Remarks

The IsEditableBinding binding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value. The IsEditableDefault property can also be set (if IsEditableBinding is not used) to designate the default return value of this method, and that can be set in XAML.

GetIsEditing(TreeListBox, object)

Returns whether the specified item is currently being edited.

public virtual bool GetIsEditing(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

bool:

true if the specified item is currently being edited; otherwise, false.

Remarks

The IsEditingBinding binding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

GetIsExpanded(TreeListBox, object)

Returns whether the specified item is expanded.

public virtual bool GetIsExpanded(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

bool:

true if the specified item is expanded; otherwise, false.

Remarks

The IsExpandedBinding binding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value. The IsExpandedDefault property can also be set (if IsExpandedBinding is not used) to designate the default return value of this method, and that can be set in XAML.

GetIsLoading(TreeListBox, object)

Returns whether the specified item is currently loading children asynchronously.

public virtual bool GetIsLoading(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

bool:

true if the specified item is currently loading children asynchronously; otherwise, false.

Remarks

The IsLoadingBinding binding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

GetIsSelectable(TreeListBox, object)

Returns whether the specified item is capable of being selected.

public virtual bool GetIsSelectable(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

bool:

true if the specified item is capable of being selected; otherwise, false.

Remarks

The IsSelectableBinding binding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

GetIsSelected(TreeListBox, object)

Returns whether the specified item is selected.

public virtual bool GetIsSelected(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

bool:

true if the specified item is selected; otherwise, false.

Remarks

The IsSelectedBinding binding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

GetPath(TreeListBox, object)

Returns the item's string path, relative to its parent.

public virtual string GetPath(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

string:

The item's string path, relative to its parent.

Remarks

The PathBinding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

GetSearchText(TreeListBox, object)

Returns the item's text by which to match when searching.

public virtual string GetSearchText(TreeListBox ownerControl, object item)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to examine.

Returns

string:

The item's string search text.

Remarks

The SearchTextBinding property can be set for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to retrieve the appropriate value.

InitializeDataObject(TreeListBox, IDataObject, IEnumerable<object>)

Initializes a IDataObject based on the specified items.

public virtual DragDropEffects InitializeDataObject(TreeListBox sourceControl, IDataObject dataObject, IEnumerable<object> items)
Parameter Type Description
sourceControl TreeListBox

The source control that contains the items.

dataObject IDataObject

The IDataObject to initialize.

items IEnumerable<object>

The items to examine.

Returns

DragDropEffects:

The DragDropEffects that specifies the allowed drag/drop effects for the IDataObject.

Remarks

The default implementation of this method simply return DragDropEffects.None. Override this method to initialize the IDataObject with text and/or other data formats (such as ItemDataFormat for supporting drag/drop), and to return an appropriate DragDropEffects result.

OnDragComplete(InputPointerEventArgs, TreeListBox, DataObject, DragDropEffects)

Notifies that a drag event from the source control has completed.

public virtual void OnDragComplete(InputPointerEventArgs e, TreeListBox sourceControl, DataObject dataObject, DragDropEffects effect)
Parameter Type Description
e InputPointerEventArgs

The InputPointerEventArgs that provides related pointer information.

sourceControl TreeListBox

The source control, from which the drag occurred.

dataObject DataObject

The data object with information about what was dragged.

effect DragDropEffects

The drop effect.

Remarks

The default implementation of this method does nothing. This method can be overridden in scenarios where a custom adorner needs to be rendered near the pointer as the items are dragged, and the adorner should be removed.

OnDragHover(DragEventArgs, TreeListBox, object)

Notifies that a drag event hovered over a target item, returning whether the target item can be expanded when appropriate.

public virtual TreeItemExpandability OnDragHover(DragEventArgs e, TreeListBox targetControl, object targetItem)
Parameter Type Description
e DragEventArgs

The DragEventArgs with drag information.

targetControl TreeListBox

The target control, over which the event occurred.

targetItem object

The target item.

Returns

TreeItemExpandability:

A TreeItemExpandability that indicates if the target item should expand.

OnDragOver(DragEventArgs, TreeListBox, object, TreeItemDropArea)

Notifies that a drag event occurred over a target item, requests that appropriate updates are made to the supplied DragEventArgs, and requests that the allowed drop area is returned for visual target feedback.

public virtual TreeItemDropArea OnDragOver(DragEventArgs e, TreeListBox targetControl, object targetItem, TreeItemDropArea dropArea)
Parameter Type Description
e DragEventArgs

The DragEventArgs whose effects should be updated.

targetControl TreeListBox

The target control, over which the event occurred.

targetItem object

The target item, which could be null if dragging below the last tree item.

dropArea TreeItemDropArea

A TreeItemDropArea indicating the drop area over the target item.

Returns

TreeItemDropArea:

A TreeItemDropArea indicating the allowed drop area, which will be used for visual feedback to the end user. Return TreeItemDropArea.None for no visual feedback.

Remarks

The default implementation of this method sets the e.Effects to DragDropEffects.None and returns that no drop area is allowed. Override this method if you wish to support dropping and add logic to properly handle the dragged data.

OnDragStart(InputPointerEventArgs, TreeListBox, DataObject, DragDropEffects)

Notifies that a drag event is about to originate from the source control.

public virtual void OnDragStart(InputPointerEventArgs e, TreeListBox sourceControl, DataObject dataObject, DragDropEffects allowedEffects)
Parameter Type Description
e InputPointerEventArgs

The InputPointerEventArgs that provides related pointer information.

sourceControl TreeListBox

The source control, from which the drag will take place.

dataObject DataObject

The data object with information about what will be dragged.

allowedEffects DragDropEffects

The allowed effects.

Remarks

The default implementation of this method does nothing. This method can be overridden in scenarios where a custom adorner needs to be rendered near the pointer as the items are dragged, and the adorner should be created.

OnDrop(DragEventArgs, TreeListBox, object, TreeItemDropArea)

Notifies that a drop event occurred over a target item and requests that appropriate updates are made to the supplied DragEventArgs.

public virtual void OnDrop(DragEventArgs e, TreeListBox targetControl, object targetItem, TreeItemDropArea dropArea)
Parameter Type Description
e DragEventArgs

The DragEventArgs whose effects should be updated.

targetControl TreeListBox

The target control, over which the event occurred.

targetItem object

The target item, which could be null if dragging below the last tree item.

dropArea TreeItemDropArea

A TreeItemDropArea indicating the drop area over the target item.

Remarks

The default implementation of this method sets the e.Effects to DragDropEffects.None and takes no further action. Override this method if you wish to support dropping and add logic to properly handle the dragged data.

SetIsEditing(TreeListBox, object, bool)

Sets whether the specified item is currently being edited.

public virtual void SetIsEditing(TreeListBox ownerControl, object item, bool value)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to update.

value bool

The new value.

Remarks

The IsEditingBinding binding property can be set to a two-way binding for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to set the appropriate value.

SetIsExpanded(TreeListBox, object, bool)

Sets whether the specified item is expanded.

public virtual void SetIsExpanded(TreeListBox ownerControl, object item, bool value)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to update.

value bool

The new value.

Remarks

The IsExpandedBinding binding property can be set to a two-way binding for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to set the appropriate value.

SetIsSelected(TreeListBox, object, bool)

Sets whether the specified item is selected.

public virtual void SetIsSelected(TreeListBox ownerControl, object item, bool value)
Parameter Type Description
ownerControl TreeListBox

The owner control.

item object

The item to update.

value bool

The new value.

Remarks

The IsSelectedBinding binding property can be set to a two-way binding for a pure XAML-based implementation of this method. Please note that bindings aren't as performant as code, so for large trees or if you see performance issues, it is recommended to override this method instead with custom logic to set the appropriate value.

Inherited Members