# TreeView

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/struct-treeview/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct TreeView
```

Displays a hierarchical tree of data.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L27)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`should_trigger_selection`](#function-should_trigger_selection)
- [`should_trigger_selection_key`](#function-should_trigger_selection_key)
- [`update_selection_from_event`](#function-update_selection_from_event)
- [`auto_scroll_to_selected_item_property`](#function-auto_scroll_to_selected_item_property)
- [`selected_item_property`](#function-selected_item_property)
- [`selected_items_property`](#function-selected_items_property)
- [`selection_mode_property`](#function-selection_mode_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`selection_changed`](#function-selection_changed)
- [`auto_scroll_to_selected_item`](#function-auto_scroll_to_selected_item)
- [`set_auto_scroll_to_selected_item`](#function-set_auto_scroll_to_selected_item)
- [`selection_mode`](#function-selection_mode)
- [`set_selection_mode`](#function-set_selection_mode)
- [`selected_item`](#function-selected_item)
- [`set_selected_item`](#function-set_selected_item)
- [`selected_items`](#function-selected_items)
- [`set_selected_items`](#function-set_selected_items)
- [`expand_sub_tree`](#function-expand_sub_tree)
- [`collapse_sub_tree`](#function-collapse_sub_tree)
- [`select_all`](#function-select_all)
- [`unselect_all`](#function-unselect_all)
- [`get_realized_tree_containers`](#function-get_realized_tree_containers)
- [`tree_container_from_item`](#function-tree_container_from_item)
- [`tree_item_from_container`](#function-tree_item_from_container)
- [`update_selection_from_container`](#function-update_selection_from_container)
- [`update_selection_from_event_source`](#function-update_selection_from_event_source)
- [`get_container_from_event_source`](#function-get_container_from_event_source)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L37)

<a id="function-to_ref"></a>

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<TreeView>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L37)

<a id="function-should_trigger_selection"></a>

### should_trigger_selection

```rust
fn should_trigger_selection(self: &Self, selectable: &Visual, event_args: &PointerEventArgs) -> bool
```

Analyses a pointer event received by a selectable element, and
determines whether the action should trigger selection on press,
on release, or not at all.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L37)

<a id="function-should_trigger_selection_key"></a>

### should_trigger_selection_key

```rust
fn should_trigger_selection_key(self: &Self, selectable: &Visual, event_args: &KeyEventArgs) -> bool
```

Analyses a key event received by a selectable element, and
determines whether the action should trigger selection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L37)

<a id="function-update_selection_from_event"></a>

### update_selection_from_event

```rust
fn update_selection_from_event(self: &Self, container: &Ref<Control>, event_args: &dyn IRoutedEventArgs) -> bool
```

Updates the selection based on an event that may have originated
in a container that belongs to the control.

Returns true if the event originated from a container that
belongs to the control and triggered selection; otherwise false.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L37)

<a id="function-auto_scroll_to_selected_item_property"></a>

### auto_scroll_to_selected_item_property

```rust
fn auto_scroll_to_selected_item_property() -> &'static StyledProperty<bool>
```

Defines the `AutoScrollToSelectedItem` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L248)

<a id="function-selected_item_property"></a>

### selected_item_property

```rust
fn selected_item_property() -> &'static DirectProperty<TreeView, Option<BoxedValue>>
```

Defines the `SelectedItem` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L248)

<a id="function-selected_items_property"></a>

### selected_items_property

```rust
fn selected_items_property() -> &'static DirectProperty<TreeView, Option<SelectedItemsList>>
```

Defines the `SelectedItems` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L248)

<a id="function-selection_mode_property"></a>

### selection_mode_property

```rust
fn selection_mode_property() -> &'static StyledProperty<SelectionMode>
```

Defines the `SelectionMode` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L248)

<a id="function-construct"></a>

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L295)

<a id="function-new"></a>

### new

```rust
fn new() -> Ref<Self>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L307)

<a id="function-selection_changed"></a>

### selection_changed

```rust
fn selection_changed(self: &Self, handler: impl Fn(&Interactive, &SelectionChangedEventArgs) -> () + 'static) -> RoutedEventHandlerToken
```

Occurs when the control's selection changes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L312)

<a id="function-auto_scroll_to_selected_item"></a>

### auto_scroll_to_selected_item

```rust
fn auto_scroll_to_selected_item(self: &Self) -> bool
```

Gets or sets a value indicating whether to automatically scroll to
newly selected items.

This property is of limited use with `TreeView` as it will only
scroll to realized items. To scroll to a non-expanded item, you need
to ensure that its ancestors are expanded.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L325)

<a id="function-set_auto_scroll_to_selected_item"></a>

### set_auto_scroll_to_selected_item

```rust
fn set_auto_scroll_to_selected_item(self: &Self, value: bool)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L329)

<a id="function-selection_mode"></a>

### selection_mode

```rust
fn selection_mode(self: &Self) -> SelectionMode
```

Gets or sets the selection mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L334)

<a id="function-set_selection_mode"></a>

### set_selection_mode

```rust
fn set_selection_mode(self: &Self, value: SelectionMode)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L338)

<a id="function-selected_item"></a>

### selected_item

```rust
fn selected_item(self: &Self) -> Option<BoxedValue>
```

Gets or sets the selected item.

Note that setting this property only currently works if the item is
expanded to be visible.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L346)

<a id="function-set_selected_item"></a>

### set_selected_item

```rust
fn set_selected_item(self: &Self, value: Option<BoxedValue>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L350)

<a id="function-selected_items"></a>

### selected_items

```rust
fn selected_items(self: &Self) -> SelectedItemsList
```

Gets or sets the selected items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L365)

<a id="function-set_selected_items"></a>

### set_selected_items

```rust
fn set_selected_items(self: &Self, value: Option<SelectedItemsList>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L378)

<a id="function-expand_sub_tree"></a>

### expand_sub_tree

```rust
fn expand_sub_tree(self: &Self, item: &TreeViewItem)
```

Expands the specified `TreeViewItem` and all its descendent
`TreeViewItem`s.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L388)

<a id="function-collapse_sub_tree"></a>

### collapse_sub_tree

```rust
fn collapse_sub_tree(self: &Self, item: &TreeViewItem)
```

Collapses the specified `TreeViewItem` and all its descendent
`TreeViewItem`s.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L408)

<a id="function-select_all"></a>

### select_all

```rust
fn select_all(self: &Self)
```

Selects all items in the `TreeView`.

Note that this method only selects nodes currently visible due to
their parent nodes being expanded: it does not expand nodes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L424)

<a id="function-unselect_all"></a>

### unselect_all

```rust
fn unselect_all(self: &Self)
```

Deselects all items in the `TreeView`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L446)

<a id="function-get_realized_tree_containers"></a>

### get_realized_tree_containers

```rust
fn get_realized_tree_containers(self: &Self) -> Vec<Ref<Control>>
```

Gets the currently realized containers of the whole tree.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L451)

<a id="function-tree_container_from_item"></a>

### tree_container_from_item

```rust
fn tree_container_from_item(self: &Self, item: &Option<BoxedValue>) -> Option<Ref<Control>>
```

Returns the container of the specified item, searching the whole
tree.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L468)

<a id="function-tree_item_from_container"></a>

### tree_item_from_container

```rust
fn tree_item_from_container(self: &Self, container: &Ref<Control>) -> Option<BoxedValue>
```

Returns the item of the specified container, searching the whole
tree.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L490)

<a id="function-update_selection_from_container"></a>

### update_selection_from_container

```rust
fn update_selection_from_container(self: &Self, container: &Ref<Control>, select: bool, range_modifier: bool, toggle_modifier: bool, right_button: bool)
```

Updates the selection for an item based on user interaction.

`select` is whether the item should be selected or unselected,
`range_modifier` whether the range modifier is enabled (i.e. the
shift key), `toggle_modifier` whether the toggle modifier is enabled
(i.e. the control key) and `right_button` whether the event is a
right-click.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L758)

<a id="function-update_selection_from_event_source"></a>

### update_selection_from_event_source

```rust
fn update_selection_from_event_source(self: &Self, event_source: Option<Ref<FerroObject>>, select: bool, range_modifier: bool, toggle_modifier: bool, right_button: bool) -> bool
```

Updates the selection based on an event that may have originated in
a container that belongs to the control.

`event_source` is the control that raised the event; the other
arguments are those of
`update_selection_from_container`.

Returns true if the event originated from a container that belongs
to the control; otherwise false.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L907)

<a id="function-get_container_from_event_source"></a>

### get_container_from_event_source

```rust
fn get_container_from_event_source(self: &Self, event_source: Option<Ref<FerroObject>>) -> Option<Ref<TreeViewItem>>
```

Tries to get the container that was the source of an event.

Returns the container or `None` if the event did not originate in a
container.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/tree_view.rs#L935)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`TemplatedControlImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimplext/)
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- [`ItemsControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-itemscontrolimplext/)
- [`TreeViewImplExt`](/docs/0.5.0/api/ferroui-controls/trait-treeviewimplext/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<TreeView>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`TemplatedControlImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`ItemsControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-itemscontrolimpl/)
- [`TreeViewImpl`](/docs/0.5.0/api/ferroui-controls/trait-treeviewimpl/)
- [`ICustomKeyboardNavigation`](/docs/0.5.0/api/ferroui-base/input/trait-icustomkeyboardnavigation/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
