Skip to main content

TextCell<T> Class

Definition

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

Represents a cell in a Avalonia.Controls.Models.TreeDataGrid that displays and edits text values.

public class TextCell<T>

Inheritance: object -> NotifyingBase -> TextCell<T>

Implements: ICell, ITextCell, IEditableObject, IDisposable

Remarks

The Avalonia.Controls.Models.TreeDataGrid.TextCell<T> class provides text display and editing functionality within a TreeDataGrid cell, supporting various text formatting options such as trimming, wrapping, and alignment.

This class serves as the data model that backs the Avalonia.Controls.Primitives.TreeDataGridTextCell primitive control. The primitive control handles UI rendering and user interactions, while this model manages the underlying data, state, and edit operations.

The generic type parameter T allows the cell to store values of any type, which are converted to and from string representations as needed for display and editing.

Constructors

NameDescription
TextCell<T> (2 overloads)No summary available.

TextCell<T> overloads

TextCell<T> Constructor

public TextCell<T>(IObserver<Avalonia.Data.BindingValue<T>> bindingSubject, IObservable<Avalonia.Data.BindingValue<T>> bindingObservable, bool isReadOnly, Avalonia.Controls.Models.TreeDataGrid.ITextCellOptions options)
Parameters

bindingSubject IObserver<Avalonia.Data.BindingValue<T>>

bindingObservable IObservable<Avalonia.Data.BindingValue<T>>

isReadOnly bool

options Avalonia.Controls.Models.TreeDataGrid.ITextCellOptions

TextCell<T> Constructor

Initializes a new instance of the Avalonia.Controls.Models.TreeDataGrid.TextCell<T> class with a fixed value.

public TextCell<T>(T value)
Parameters

value T

The value to be displayed in the cell.

Remarks

This constructor creates a read-only text cell with the specified value. The value will be converted to a string representation for display.

Methods

NameDescription
BeginEditBegins an edit operation on the cell.
CancelEditCancels the current edit operation and restores the original value.
DisposeReleases resources used by the Avalonia.Controls.Models.TreeDataGrid.TextCell<T>.
EndEditCommits the current edit operation and applies the changes to the cell value.

BeginEdit Method

Begins an edit operation on the cell.

public void BeginEdit()

Remarks

When edit mode is entered, the current text representation of the value is stored in an edit buffer. Changes to the Avalonia.Controls.Models.TreeDataGrid.TextCell<T>.Text property during edit mode update this buffer rather than the underlying value.

The edit must be completed with Avalonia.Controls.Models.TreeDataGrid.TextCell<T>.EndEdit or canceled with Avalonia.Controls.Models.TreeDataGrid.TextCell<T>.CancelEdit.

CancelEdit Method

Cancels the current edit operation and restores the original value.

public void CancelEdit()

Remarks

Discards any changes made to the Avalonia.Controls.Models.TreeDataGrid.TextCell<T>.Text property since Avalonia.Controls.Models.TreeDataGrid.TextCell<T>.BeginEdit was called.

Dispose Method

Releases resources used by the Avalonia.Controls.Models.TreeDataGrid.TextCell<T>.

public void Dispose()

EndEdit Method

Commits the current edit operation and applies the changes to the cell value.

public void EndEdit()

Remarks

Converts the current edit text to a value of type T and assigns it to the Avalonia.Controls.Models.TreeDataGrid.TextCell<T>.Value property.

If the cell has a binding, the new value is propagated to the bound source.

Properties

NameDescription
CanEditGets a value indicating whether the cell can enter edit mode.
EditGesturesGets the gestures that cause the cell to enter edit mode.
IsReadOnlyGets a value indicating whether the cell is read-only.
TextGets or sets the cell's value as a string.
TextAlignmentGets the text alignment mode for the cell.
TextTrimmingGets the text trimming mode for the cell.
TextWrappingGets the text wrapping mode for the cell.
ValueGets or sets the strongly-typed value of the cell.

CanEdit Property

Gets a value indicating whether the cell can enter edit mode.

public bool CanEdit { get; set; }

Remarks

Returns true if the cell is not read-only; otherwise, false.

EditGestures Property

Gets the gestures that cause the cell to enter edit mode.

public Avalonia.Controls.Models.TreeDataGrid.BeginEditGestures EditGestures { get; set; }

Remarks

Returns the edit gestures specified in the cell options, or the default gestures if not specified. Default gestures include F2 key press and double-tap.

IsReadOnly Property

Gets a value indicating whether the cell is read-only.

public bool IsReadOnly { get; set; }

Remarks

When true, the cell's value cannot be changed by the user through the UI.

Text Property

Gets or sets the cell's value as a string.

public string Text { get; set; }

Remarks

When getting this property, it returns the string representation of the cell's value, applying any string formatting specified in the cell options.

When setting this property, it attempts to convert the string to the appropriate value type and update the cell's value. If the cell is in edit mode, it updates the edit buffer instead.

TextAlignment Property

Gets the text alignment mode for the cell.

public Avalonia.Media.TextAlignment TextAlignment { get; set; }

Remarks

Determines how text is aligned horizontally within the cell. Returns the alignment specified in the cell options, or Avalonia.Media.TextAlignment.Left if not specified.

TextTrimming Property

Gets the text trimming mode for the cell.

public Avalonia.Media.TextTrimming TextTrimming { get; set; }

Remarks

Determines how text is trimmed when it doesn't fit within the cell's bounds. Returns the trimming mode specified in the cell options, or Avalonia.Media.TextTrimming.None if not specified.

TextWrapping Property

Gets the text wrapping mode for the cell.

public Avalonia.Media.TextWrapping TextWrapping { get; set; }

Remarks

Determines whether and how text wraps within the cell. Returns the wrapping mode specified in the cell options, or Avalonia.Media.TextWrapping.NoWrap if not specified.

Value Property

Gets or sets the strongly-typed value of the cell.

public T Value { get; set; }

Remarks

When setting this property, if the cell is not read-only and not in edit mode, the change is propagated to the binding.

Events

NameDescription
PropertyChangedOccurs when a property value changes. Inherited from NotifyingBase.