Table of Contents

Class MudTreeViewItem<T>

Namespace
MudBlazor
Assembly
MudBlazor.dll

An expandable branch of a MudTreeView<T>.

public class MudTreeViewItem<T> : MudComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IDisposable

Type Parameters

T

The type of the selectable value held by the item.

Inheritance
MudTreeViewItem<T>
Implements
Inherited Members
Extension Methods

Remarks

Used as the data model of the tree.

Constructors

MudTreeViewItem()

public MudTreeViewItem()

Properties

BodyContent

The custom content for the text, end text, and end icon.

[Parameter]
[Category("Behavior")]
public RenderFragment<MudTreeViewItem<T?>>? BodyContent { get; set; }

Property Value

RenderFragment<MudTreeViewItem<T>>

Remarks

When set, the Text, EndText, and EndIcon properties are ignored.

CanExpand

Allows this item to expand to display children.

[Parameter]
[Category("Behavior")]
public bool CanExpand { get; set; }

Property Value

bool

Remarks

Defaults to true. A value of false is typically used for lazy-loaded items via ServerData.

ChildContent

The child items within this item.

[Parameter]
[Category("Data")]
public RenderFragment? ChildContent { get; set; }

Property Value

RenderFragment

Remarks

Must be one or more MudTreeViewItem<T> components. Only applies when Content is not set.

Classname

protected string Classname { get; }

Property Value

string

Content

The custom content within this item.

[Parameter]
[Category("Behavior")]
public RenderFragment? Content { get; set; }

Property Value

RenderFragment

Remarks

When set, completely controls the rendering of child items. For MudTreeViewItem<T> children, use Items or ChildContent.

ContentClassname

protected string ContentClassname { get; }

Property Value

string

Disabled

Prevents the user from interacting with this item.

[Parameter]
[Category("Behavior")]
public bool Disabled { get; set; }

Property Value

bool

Remarks

Defaults to false.

EndIcon

Icon placed after the text if set.

[Parameter]
[Category("Behavior")]
public string? EndIcon { get; set; }

Property Value

string

Remarks

Ignored if BodyContent is set.

EndIconColor

The color of the end icon when EndIcon is set.

[Parameter]
[Category("Appearance")]
public Color EndIconColor { get; set; }

Property Value

Color

Remarks

Defaults to Default.

EndText

The text at the end of the item.

[Parameter]
[Category("Behavior")]
public string? EndText { get; set; }

Property Value

string

Remarks

Ignored if BodyContent is set.

EndTextClass

The CSS classes applied to the EndText parameter.

[Parameter]
[Category("Appearance")]
public string? EndTextClass { get; set; }

Property Value

string

Remarks

Defaults to null. Multiple values must be separated by spaces.

EndTextTypo

The size of the end text.

[Parameter]
[Category("Appearance")]
public Typo EndTextTypo { get; set; }

Property Value

Typo

Remarks

Defaults to body1.

ExpandButtonIcon

The icon shown for the expand/collapse button.

[Parameter]
[Category("Expanding")]
public string ExpandButtonIcon { get; set; }

Property Value

string

Remarks

Defaults to ChevronRight.

ExpandButtonIconColor

The color of the expand/collapse button.

[Parameter]
[Category("Expanding")]
public Color ExpandButtonIconColor { get; set; }

Property Value

Color

Remarks

Defaults to Default.

Expanded

Shows the children items underneath this item.

[Parameter]
[Category("Expanding")]
public bool Expanded { get; set; }

Property Value

bool

Remarks

Defaults to false.

ExpandedChanged

Occurs when Expanded has changed.

[Parameter]
public EventCallback<bool> ExpandedChanged { get; set; }

Property Value

EventCallback<bool>

Icon

The item shown before the text.

[Parameter]
[Category("Behavior")]
public string? Icon { get; set; }

Property Value

string

Remarks

Defaults to null.

IconColor

The color of the icon when Icon is set.

[Parameter]
[Category("Appearance")]
public Color IconColor { get; set; }

Property Value

Color

Remarks

Defaults to Default.

IconExpanded

The icon shown when this item is expanded.

[Parameter]
[Category("Behavior")]
public string? IconExpanded { get; set; }

Property Value

string

Remarks

Defaults to null.

Items

The child items underneath this item.

[Parameter]
[Category("Data")]
public IReadOnlyCollection<TreeItemData<T?>>? Items { get; set; }

Property Value

IReadOnlyCollection<TreeItemData<T>>

ItemsChanged

Occurs when Items has changed.

[Parameter]
public EventCallback<IReadOnlyCollection<TreeItemData<T?>>?> ItemsChanged { get; set; }

Property Value

EventCallback<IReadOnlyCollection<TreeItemData<T>>>

LoadingIcon

The icon shown while this item is loading.

[Parameter]
[Category("Appearance")]
public string LoadingIcon { get; set; }

Property Value

string

Remarks

Defaults to Loop.

LoadingIconColor

The color of the loading icon.

[Parameter]
[Category("Appearance")]
public Color LoadingIconColor { get; set; }

Property Value

Color

Remarks

Defaults to Default.

OnClick

Occurs when this item has been clicked.

[Parameter]
public EventCallback<MouseEventArgs> OnClick { get; set; }

Property Value

EventCallback<MouseEventArgs>

OnDoubleClick

Occurs when this item has been double-clicked.

[Parameter]
public EventCallback<MouseEventArgs> OnDoubleClick { get; set; }

Property Value

EventCallback<MouseEventArgs>

ReadOnly

Prevents this item from being selected.

[Parameter]
[Category("Behavior")]
public bool ReadOnly { get; set; }

Property Value

bool

Remarks

Defaults to false.

Selected

Selects this item.

[Parameter]
[Category("Selecting")]
public bool Selected { get; set; }

Property Value

bool

Remarks

Defaults to false. Can be set alongside other items if SelectionMode is MultiSelection or ToggleSelection.

SelectedChanged

Occurs when Selected has changed.

[Parameter]
public EventCallback<bool> SelectedChanged { get; set; }

Property Value

EventCallback<bool>

Text

The text to display.

[Parameter]
[Category("Behavior")]
public string? Text { get; set; }

Property Value

string

Remarks

Defaults to null. When no value is set, the Value is used if it is a basic value such as string or int, etc.
Ignored if BodyContent is set.

TextClass

The CSS classes applied to the Text parameter.

[Parameter]
[Category("Appearance")]
public string? TextClass { get; set; }

Property Value

string

Remarks

Defaults to null. Multiple values must be separated by spaces.

TextClassname

public string TextClassname { get; }

Property Value

string

TextTypo

The size of the text.

[Parameter]
[Category("Appearance")]
public Typo TextTypo { get; set; }

Property Value

Typo

Remarks

Defaults to body1.

Value

The value associated with this item.

[Parameter]
[Category("Data")]
public T? Value { get; set; }

Property Value

T

Remarks

Defaults to null. Acts as the displayed text if no text is set.

Visible

Whether this item and its children are displayed.

[Parameter]
[Category("Appearance")]
public bool Visible { get; set; }

Property Value

bool

Remarks

Defaults to true.

Methods

BuildRenderTree(RenderTreeBuilder)

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

CollapseAllAsync()

Collapse this item and all children recursively.

public Task CollapseAllAsync()

Returns

Task

Dispose()

Disposes the resources used by this component.

public void Dispose()

ExpandAllAsync()

Expands this item and all children recursively.

public Task ExpandAllAsync()

Returns

Task

OnInitializedAsync()

protected override Task OnInitializedAsync()

Returns

Task

OnParametersSet()

protected override void OnParametersSet()

ReloadAsync()

Clears the children under this item.

public Task ReloadAsync()

Returns

Task

See Also