Skip to content

TextBox class

Defined in

Namespace: CrissCross.Avalonia.UI.Controls Assembly: CrissCross.Avalonia.UI.dll Full name: CrissCross.Avalonia.UI.Controls.TextBox Modifiers: public

Summary

        Represents a text input control that supports placeholder text, an optional icon, and a clear button, with
        additional customization options for user interaction.
        

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net471

Class hierarchy
classDiagram
class TextBox
class TextBox
TextBox <|-- TextBox

Inherits from: TextBox

Remarks

The TextBox control extends the standard Avalonia TextBox by providing features such as configurable placeholder text, an optional icon with customizable placement, and a clear button that can be enabled or disabled. The clear button appears when the control is focused and contains text, allowing users to quickly clear the input. The control also exposes commands for template button interactions and supports enabling or disabling text selection. These features make it suitable for scenarios where enhanced user experience and input customization are required.

Constructors

NameSummary
.ctorInitializes a new instance of the [TextBox](# class.

Properties

NameSummary
IconGets or sets displayed icon.
IconPlacementGets or sets which side the icon should be placed on.
PlaceholderTextGets or sets placeholder text.
PlaceholderEnabledGets or sets a value indicating whether to enable the placeholder text.
CurrentPlaceholderEnabledGets or sets a value indicating whether to display the placeholder text.
ClearButtonEnabledGets or sets a value indicating whether to enable the clear button.
ShowClearButtonGets or sets a value indicating whether to show the clear button when [TextBox](# is focused.
IsTextSelectionEnabledGets or sets a value indicating whether text selection is enabled.
TemplateButtonCommandGets the command triggered when clicking the button.

Fields

NameSummary
static IconPropertyProperty for [Icon](#
static IconPlacementPropertyProperty for [IconPlacement](#
static PlaceholderTextPropertyProperty for [PlaceholderText](#
static PlaceholderEnabledPropertyProperty for [PlaceholderEnabled](#
static CurrentPlaceholderEnabledPropertyProperty for [CurrentPlaceholderEnabled](#
static ClearButtonEnabledPropertyProperty for [ClearButtonEnabled](#
static ShowClearButtonPropertyProperty for [ShowClearButton](#
static IsTextSelectionEnabledPropertyProperty for [IsTextSelectionEnabled](#
static TemplateButtonCommandPropertyProperty for [TemplateButtonCommand](#

Methods

NameSummary
OnPropertyChangedCalled when a avalonia property changes on the object.
OnTextChangedCalled when text changes.
SetPlaceholderTextVisibilitySets the placeholder text visibility.
OnGotFocusInvoked when an unhandled GotFocusEvent reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
OnLostFocusInvoked when an unhandled LostFocusEvent reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
RevealClearButtonReveals the clear button by [ShowClearButton](# property.
HideClearButtonHides the clear button by [ShowClearButton](# property.
OnClearButtonClickTriggered when the user clicks the clear text button.
OnTemplateButtonClickTriggered by clicking a button in the control template.
OnPlaceholderEnabledChangedCalled when placeholder enabled property changes.

Derived types

Inherited members