跳到主要内容

TreeDataGrid Quick Start Guide

Overview

The Avalonia TreeDataGrid is a control which displays hierarchical and tabular data together in a single view. It is a combination of a TreeView and DataGrid control.

The control has two modes of operation:

  • Hierarchical: data is displayed in a tree with optional columns
  • Flat: data is displayed in a 2D table, similar to other DataGrid controls

Installation

See the Installation Guide for step-by-step instructions on how to install Accelerate components.

Add the TreeDataGrid package to your project:

dotnet add package Avalonia.Controls.TreeDataGrid

Add the License Key

Include your Avalonia UI license key in the executable project file (.csproj):

<ItemGroup>
<AvaloniaUILicenseKey Include="YOUR_LICENSE_KEY" />
</ItemGroup>
提示

For multi-project solutions, you can store your license key in an environment variable or a shared props file to avoid duplication.

Install the Theme

The theme for TreeDataGrid must be installed into your App.axaml in order for anything to appear:

<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyApp"
RequestedThemeVariant="Default">
<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.TreeDataGrid/Themes/Fluent.axaml"/>
</Application.Styles>
</Application>

Basic Usage

See: