# TreeNodeExtensions

Namespace: **Wisej.Web.Markup**

Assembly: **Wisej.Framework** (4.0.0.0)

Adds [fluent markup](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/markup/markup) extension methods to the [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md) class.

{% tabs %}
{% tab title="C#" %}

```csharp
public class TreeNodeExtensions
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class TreeNodeExtensions
```

{% endtab %}
{% endtabs %}

## Methods

### ![](/files/lIX317sDtMTZJBi9oSIx) Checked\<TTreeNode>(treeNode, value)

Sets the checked state of the tree node.

| Parameter     | Type                                                                                 | Description                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md) | The tree node to set the checked state on.                                                                                    |
| **value**     | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                      | A boolean value indicating whether the node is checked.                                                                       |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The modified tree node with the checked state set.

### ![](/files/lIX317sDtMTZJBi9oSIx) LazyLoading\<TTreeNode>(treeNode, value)

Sets the lazy loading property of the tree node.

| Parameter     | Type                                                                                 | Description                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md) | The tree node to set the lazy loading property on.                                                                            |
| **value**     | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                      | A boolean value indicating whether lazy loading is enabled.                                                                   |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The modified tree node with the lazy loading property set.

### ![](/files/lIX317sDtMTZJBi9oSIx) Nodes\<TTreeNode>(treeNode, nodes)

Adds an array of child nodes to the specified [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md).

| Parameter     | Type                                                                                 | Description                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md) | The tree node to which the child nodes will be added.                                                                         |
| **nodes**     | [TreeNode\[\]](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md)        | An array of tree nodes to be added as children.                                                                               |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the updated child nodes.

This method allows you to add multiple child nodes to a tree node in a tree view control.

```csharp

myTreeNode.Nodes(new TreeNode("Child1"), new TreeNode("Child2"));

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnAfterCheck\<TTreeNode>(treeNode, action)

Attaches an action to be executed after the tree node is checked.

| Parameter     | Type                                                                                 | Description                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md) | The tree node to attach the action to.                                                                                        |
| **action**    | [Action\<TTreeNode>](https://docs.microsoft.com/dotnet/api/system.action-1)          | The action to execute after the node is checked.                                                                              |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the action attached.

This method allows you to perform custom logic after a tree node's checked state changes.

```csharp

treeNode.OnAfterCheck(node => { /* custom logic */ });

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnAfterCollapse\<TTreeNode>(treeNode, action)

Attaches an action to be executed after the tree node is collapsed.

| Parameter     | Type                                                                                 | Description                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md) | The tree node to attach the action to.                                                                                        |
| **action**    | [Action\<TTreeNode>](https://docs.microsoft.com/dotnet/api/system.action-1)          | The action to execute after the node is collapsed.                                                                            |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the action attached.

This method allows you to perform custom logic after a tree node is collapsed.

```csharp

treeNode.OnAfterCollapse(node => { /* custom logic */ });

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnAfterExpand\<TTreeNode>(treeNode, action)

Attaches an action to be executed after the tree node is expanded.

| Parameter     | Type                                                                                 | Description                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md) | The tree node to attach the action to.                                                                                        |
| **action**    | [Action\<TTreeNode>](https://docs.microsoft.com/dotnet/api/system.action-1)          | The action to execute after the node is expanded.                                                                             |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the action attached.

This method allows you to perform custom logic after a tree node is expanded.

```csharp

treeNode.OnAfterExpand(node => { /* custom logic */ });

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnAfterSelect\<TTreeNode>(treeNode, action)

Attaches an action to be executed after the tree node is selected.

| Parameter     | Type                                                                                 | Description                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md) | The tree node to attach the action to.                                                                                        |
| **action**    | [Action\<TTreeNode>](https://docs.microsoft.com/dotnet/api/system.action-1)          | The action to execute after the node is selected.                                                                             |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the action attached.

This method allows you to perform custom logic after a tree node is selected.

```csharp

treeNode.OnAfterSelect(node => { /* custom logic */ });

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnBeforeCheck\<TTreeNode>(treeNode, action)

Attaches an action to be executed before the tree node is checked.

| Parameter     | Type                                                                                                 | Description                                                                                                                   |
| ------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md)                 | The tree node to attach the action to.                                                                                        |
| **action**    | [Action\<TTreeNode, TreeViewCancelEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2) | The action to execute before the node is checked.                                                                             |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the action attached.

This method allows you to perform custom logic before a tree node's checked state changes.

```csharp

treeNode.OnBeforeCheck((node, args) => { /* custom logic */ });

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnBeforeCollapse\<TTreeNode>(treeNode, action)

Attaches an action to be executed before the tree node is collapsed.

| Parameter     | Type                                                                                                 | Description                                                                                                                   |
| ------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md)                 | The tree node to attach the action to.                                                                                        |
| **action**    | [Action\<TTreeNode, TreeViewCancelEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2) | The action to execute before the node is collapsed.                                                                           |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the action attached.

This method allows you to perform custom logic before a tree node is collapsed.

```csharp

treeNode.OnBeforeCollapse((node, args) => { /* custom logic */ });

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnBeforeExpand\<TTreeNode>(treeNode, action)

Attaches an action to be executed before the tree node is expanded.

| Parameter     | Type                                                                                                 | Description                                                                                                                   |
| ------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md)                 | The tree node to attach the action to.                                                                                        |
| **action**    | [Action\<TTreeNode, TreeViewCancelEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2) | The action to execute before the node is expanded.                                                                            |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the action attached.

This method allows you to perform custom logic before a tree node is expanded.

```csharp

treeNode.OnBeforeExpand((node, args) => { /* custom logic */ });

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnBeforeSelect\<TTreeNode>(treeNode, action)

Attaches an action to be executed before the tree node is selected.

| Parameter     | Type                                                                                                 | Description                                                                                                                   |
| ------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md)                 | The tree node to attach the action to.                                                                                        |
| **action**    | [Action\<TTreeNode, TreeViewCancelEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2) | The action to execute before the node is selected.                                                                            |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The tree node with the action attached.

This method allows you to perform custom logic before a tree node is selected.

```csharp

treeNode.OnBeforeSelect((node, args) => { /* custom logic */ });

```

### ![](/files/lIX317sDtMTZJBi9oSIx) ShowLoader\<TTreeNode>(treeNode, value)

Sets the show loader property of the tree node.

| Parameter     | Type                                                                                 | Description                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| **TTreeNode** |                                                                                      | The type of the tree node, which must inherit from [TreeNode](/api/wisej.web/lists-and-grids/treeview/wisej.web.treenode.md). |
| **treeNode**  | [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md) | The tree node to set the show loader property on.                                                                             |
| **value**     | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                      | A boolean value indicating whether the loader should be shown.                                                                |

**Returns:** [TTreeNode](/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md). The modified tree node with the show loader property set.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.treenodeextensions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
