Docs / UI

Glossary: TreeViewItem

The properties, methods and events of TreeViewItem, in alphabetical order.

Color legend plain property dependency property method

An item of a tree view: an expand icon and its content, with leaves below it. Items added in code can be made with the constructor; the items of source objects are made by the tree view. When an item is added to another item, it gets its place in the tree: its indentation is set by the item it joins. It keeps its own Name; the items the tree view makes (around your elements, for texts and for source objects) are named after the item they join.

TreeViewItem derives from BaseElement and has its members too. The lists and menus page shows it in context, with code and screenshots.

Names are colored by what they are: a plain property, a method, an event or a dependency property, which a style, a binding or an animation can set.

Properties

HasLeaves 🠆

bool · Read-only. Whether the item has leaves, also an item of a source object whose children were not made into items yet.

IsExpanded 🠆

bool · Whether the leaves are shown (while the items above are expanded too). An item without leaves is never expanded. An item of a source object makes the items of its children the first time it is expanded.

Leaves 🠆

IReadOnlyList<TreeViewItem> · Read-only. The items one level below. Empty for an item of a source object until it is first expanded.

MouseCursorsSet 🠆

MouseCursorsSet · Read-only. The mouse cursors of the row the item is shown in.

Source 🠆

object · Read-only. The ItemsSource object the item shows, null for an item added in code.

Methods

TreeViewItem() 🠆

TreeViewItem(TreeView parentTreeView, BaseElement content, Margin shift, string name = null) · Creates an item of the tree view showing the content. shift is its indentation until it is added to the tree, which sets its own.

Parameter Type Description
parentTreeView TreeView The tree view the item is for: its list, icons and indentation.
content BaseElement The element the item shows.
shift Margin The item’s indentation until it is added to the tree, which sets its own; Margin.Zero will do.
name string The item’s Name until it is added to an item, which names it after itself. Default: null.

AddItem() 🠆

AddItem(BaseElement item) · Adds a leaf; an element that is not a TreeViewItem is put in one. Does nothing for an item of a source object.

Parameter Type Description
item BaseElement The element to add.

AddItemAt() 🠆

AddItemAt(BaseElement item, int index) · Inserts a leaf at the index.

Parameter Type Description
item BaseElement The element to insert.
index int The position to insert it at: 0 for the first, the number of items for the end.

AddItemsRange() 🠆

AddItemsRange(IEnumerable<BaseElement> items) · Adds leaves at the end, listed in one go.

Parameter Type Description
items IEnumerable<BaseElement> The elements to add, in order.

AddItemsRangeAt() 🠆

AddItemsRangeAt(IEnumerable<BaseElement> items, int index) · Inserts leaves at the index, listed in one go.

Parameter Type Description
items IEnumerable<BaseElement> The elements to insert, in order.
index int The position of the first one: 0 for the first, the number of items for the end.

AddTextItem() 🠆

AddTextItem(string text) · Adds a leaf showing the text in a label and returns it. The tree view made it, so it is disposed when it is removed. Does nothing and returns null for an item of a source object.

Parameter Type Description
text string The text of the item’s label.

ClearItems() 🠆

ClearItems() · Removes every leaf.

RemoveItem() 🠆

RemoveItem(BaseElement item) · Removes the item (or the item made around the element) from anywhere in this item’s branch.

Parameter Type Description
item BaseElement The element to take out.

RemoveItemAt() 🠆

RemoveItemAt(int index) · Removes the leaf at the index, with its branch.

Parameter Type Description
index int The index of the item to take out.

RemoveItemsRangeAt() 🠆

RemoveItemsRangeAt(int index, int count) · Removes count leaves from the index on.

Parameter Type Description
index int The index of the first item to take out.
count int The number of items to take out.