Skip to main content

IndentConverter Class

Definition​

Assembly:Avalonia.Controls.TreeDataGrid
Package:Avalonia.Controls.TreeDataGrid

Converts an integer indentation level to a Avalonia.Thickness value for use in hierarchical data displays.

public class IndentConverter

Inheritance: object -> IndentConverter

Implements:IValueConverter

Remarks​

IndentConverter is primarily used in the TreeDataGrid control to create appropriate left margin indentation for hierarchical data. It multiplies the input indent level by 20 device-independent pixels to create a left margin, resulting in a visual tree structure.

This converter is typically used in templates for Avalonia.Controls.Primitives.TreeDataGridExpanderCell or other controls that display hierarchical data where rows need different levels of indentation based on their depth in the hierarchy.

Example usage in XAML:

<Border Margin="{Binding Indent, Converter={x:Static converters:IndentConverter.Instance}}"/>

Constructors​

NameDescription
IndentConverterNo summary available.

IndentConverter Constructor​

public IndentConverter()

Methods​

NameDescription
ConvertConverts an integer indent value to a Avalonia.Thickness with the appropriate left margin.
ConvertBackConverts a thickness back to an integer indent value.

Convert Method​

Converts an integer indent value to a Avalonia.Thickness with the appropriate left margin.

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

Parameters​

value object

An integer representing the indentation level.

targetType Type

The type of the binding target property.

parameter object

Optional parameter (not used).

culture System.Globalization.CultureInfo

Culture information (not used).

Returns​

object

A Avalonia.Thickness where the left value is set to 20 * indent and other values are 0. Returns an empty Avalonia.Thickness if value is not an integer.

ConvertBack Method​

Converts a thickness back to an integer indent value.

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

Parameters​

value object

The thickness to convert back.

targetType Type

The type of the binding target property.

parameter object

Optional parameter (not used).

culture System.Globalization.CultureInfo

Culture information (not used).

Returns​

object

This operation is not supported and will throw NotImplementedException.

Exceptions​

Properties​

NameDescription
InstanceGets a shared instance of the Avalonia.Controls.Converters.IndentConverter.

Instance Property​

Gets a shared instance of the Avalonia.Controls.Converters.IndentConverter.

public Avalonia.Controls.Converters.IndentConverter Instance { get; set; }