Docs / UI

Glossary: TreeView Style

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

Color legend plain property dependency property method event

A tree of TreeViewItems shown as the rows of a list box. Branches open and close, and any item can be selected, a branch as well as a leaf. It is filled from data or built in code.

TreeView 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

ChildrenSelector 🠆

Func<object, IEnumerable> · Gives the children of an object of the ItemsSource, null or empty for a leaf. A children collection that is a BindableCollection<T> is followed.

ExpandedIconColor 🠆

Color · The color of the icon of an expanded branch, when the tree view has no textures. By default (90, 90, 100).

ExpandIconStyle 🠆

ImageStyle · The style of the expand icon of the items, for example its size and margin. By default an 8 by 8 block, centered, with a margin of 4 before and 6 after it.

FoldedIconColor 🠆

Color · The color of the icon of a collapsed branch, when the tree view has no textures. By default (150, 150, 160).

GeneralMouseCursorsSet 🠆

MouseCursorsSet · Static. The cursors of every element of this style type; null (the default) falls back to DefaultMouseCursorsSet.

GeneralStyle 🠆

TreeViewStyle · Static. The style of every element of this style type. It starts as a copy of the framework defaults; changing one of its properties updates every such element, a property it leaves unset takes its default.

ItemsSource 🠆

IEnumerable · The top-level objects of the tree. A BindableCollection<T> is followed.

ItemsTemplate 🠆

IItemsTemplate · Makes the element of each object; a label with the object’s text when none is set.

Leaves 🠆

IReadOnlyList<TreeViewItem> · Read-only. The top-level items.

ListBoxStyle 🠆

ListBoxStyle · The style of the list the items are shown in, for example its row colors and scroll bars. Its alignments are not used: the list always fills the tree view.

MouseCursorsSet 🠆

MouseCursorsSet · Read-only. The cursors the element shows: its override, else the set given to the control it is a part of, else its type’s general set, else DefaultMouseCursorsSet.

MouseCursorsSetOverride 🠆

MouseCursorsSet · The cursors of this element only, passed on to its parts that have none of their own.

SelectedItem 🠆

TreeViewItem · The selected item, null when nothing is selected. Only an item of this tree can be set; the branches above it are expanded.

StyleOverride 🠆

TreeViewStyle · A style for this element only, applied over the general style. Setting it to null takes its values back out.

SubItemsShift 🠆

Margin · How far each level is indented (Left) and the space above every row but the first (Top), in units. (16, 0) unless set (DefaultSettings.DefaultTreeViewSubItemsShift).

Methods

TreeView() 🠆

TreeView(string name = null) · Creates a tree view. The name is used by GetElementByName.

Parameter Type Description
name string The element’s Name, which GetElementByName finds it by. Default: null.

AddItem() 🠆

AddItem(BaseElement item) · Adds a top-level item; an element that is not a TreeViewItem is put in one. Does nothing while an ItemsSource is set.

Parameter Type Description
item BaseElement The element to add.

AddItemAt() 🠆

AddItemAt(BaseElement item, int index) · Inserts a top-level item 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 top-level items 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 top-level items 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 top-level item showing the text in a label and returns it, to nest items in it. The tree view made it, so it is disposed when it is removed. Does nothing and returns null while an ItemsSource is set.

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

ClearItems() 🠆

ClearItems() · Removes every item.

CollapseAll() 🠆

CollapseAll() · Collapses every branch.

ExpandAll() 🠆

ExpandAll() · Expands every branch, making the items of the whole data.

RemoveItem() 🠆

RemoveItem(BaseElement item) · Removes the item (or the item made around the element) from wherever it is in the tree, with its branch.

Parameter Type Description
item BaseElement The element to take out.

RemoveItemAt() 🠆

RemoveItemAt(int index) · Removes the top-level item at the index.

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

RemoveItemsRangeAt() 🠆

RemoveItemsRangeAt(int index, int count) · Removes count top-level items 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.

SelectSource() 🠆

SelectSource(object source) · Selects the item of the ItemsSource object, also one in a branch that was not expanded yet. Nothing happens when there is none.

Parameter Type Description
source object The ItemsSource object whose item is selected.

Events

OnItemSelect 🠆

(BaseElement sender, TreeViewItem item) · The selected item changes, by the user or from code. item is null when nothing is selected any more.

Parameter Type Description
sender BaseElement The element that raised the event.
item TreeViewItem The selected item, or null when nothing is selected any more.