Skip to content

Commit

Permalink
Merge pull request #770 from telerik/didi/treeview-descriptor
Browse files Browse the repository at this point in the history
Add TreeView descriptor article
  • Loading branch information
didiyordanova authored Jan 30, 2024
2 parents e3c63ca + 7ce1222 commit 0699839
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions controls/treeview/descriptor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: Item Hierarchy
page_title: .NET MAUI TreeView Documentation - Item Hierarchy
description: Learn how to define the appearance of the items in the Telerik UI for .NET MAUI TreeView control.
position: 2
slug: treeview-descriptor
---

# .NET MAUI TreeView Item Hierarchy

To specify the data items' hierarchy and how each item is visualized, use the `TreeViewDescriptor` class. For more flexibility, you can define multiple descriptors in the TreeView.

The `TreeViewDescriptor` class exposes the following properties:

| Property | Description |
| -------- | ----------- |
| `TargetType` (`System.Type`) | Specifies the type of the data item the descriptor refers to. |
| `IdentityMemberPath` (`string`) | Specifies the path to the identity member of the data item. The identifier member is used to identify the item in the hierarchy. If the property is not specified, the entire item is used instead. |
| `DisplayMemberPath ` (`string`) | Specifies the path to the display member of the data item. The display member is used to visualize the item on the screen. If the property is not specified, the entire item is used instead. |
| `ItemsSourcePath` (`string`) | Specifies the path to the child items source of the data item. |
| `ItemTemplate` (`DataTemplate`) | Specifies the template applied to the respective type of items. |
| `ItemStyle` (`Style` with a target type of `TreeViewItemView`) | Specifies the style of the TreeView items. |

> You can define multiple descriptors in the TreeView.
Here is an example demonstrating how to define the data items' hierarchy by using the TreeView descriptor:

**1.** Set up the `RadTreeView` instance:

<snippet id='treeview-getting-started-xaml' />

**2.** Add the `telerik` namespaces:

```XAML
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
```

**3.** Create a sample `Item` class:

<snippet id='treeview-getting-started-item' />

**4.** Add the `ViewModel` class:

<snippet id='treeview-getting-started-viewmodel' />

**5.** Register the Telerik controls through the `Telerik.Maui.Controls.Compatibility.UseTelerik` extension method called inside the `CreateMauiApp` method of the `MauiProgram.cs` file of your project:

```C#
using Telerik.Maui.Controls.Compatibility;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseTelerik()
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});

return builder.Build();
}
}
```

## Additional Resources

* [Expand and Collapse TreeView Items]({%slug treeview-expand-collapse%})
* [CheckBoxes in TreeView]({%slug treeview-checkboxes%})
* [Styling the TreeView Item]({%slug treeview-item-style%})
* [Scrolling options]({%slug treeview-scrolling%})
* [Multiple and Single Selection]({%slug treeview-selection%})
* [Events]({%slug treeview-events%})
* [Available Commands in .NET MAUI TreeView]({%slug treeview-commands%})

## See Also

- [.NET MAUI TreeView Product Page](https://www.telerik.com/maui-ui/treeview)
- [.NET MAUI TreeView Forum Page](https://www.telerik.com/forums/maui?tagId=2056)
- [Telerik .NET MAUI Blogs](https://www.telerik.com/blogs/mobile-net-maui)
- [Telerik .NET MAUI Roadmap](https://www.telerik.com/support/whats-new/maui-ui/roadmap)

0 comments on commit 0699839

Please sign in to comment.