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¶
| Name | Summary |
|---|---|
| .ctor | Initializes a new instance of the [TextBox](# class. |
Properties¶
| Name | Summary |
|---|---|
| Icon | Gets or sets displayed icon. |
| IconPlacement | Gets or sets which side the icon should be placed on. |
| PlaceholderText | Gets or sets placeholder text. |
| PlaceholderEnabled | Gets or sets a value indicating whether to enable the placeholder text. |
| CurrentPlaceholderEnabled | Gets or sets a value indicating whether to display the placeholder text. |
| ClearButtonEnabled | Gets or sets a value indicating whether to enable the clear button. |
| ShowClearButton | Gets or sets a value indicating whether to show the clear button when [TextBox](# is focused. |
| IsTextSelectionEnabled | Gets or sets a value indicating whether text selection is enabled. |
| TemplateButtonCommand | Gets the command triggered when clicking the button. |
Fields¶
| Name | Summary |
|---|---|
| static IconProperty | Property for [Icon](# |
| static IconPlacementProperty | Property for [IconPlacement](# |
| static PlaceholderTextProperty | Property for [PlaceholderText](# |
| static PlaceholderEnabledProperty | Property for [PlaceholderEnabled](# |
| static CurrentPlaceholderEnabledProperty | Property for [CurrentPlaceholderEnabled](# |
| static ClearButtonEnabledProperty | Property for [ClearButtonEnabled](# |
| static ShowClearButtonProperty | Property for [ShowClearButton](# |
| static IsTextSelectionEnabledProperty | Property for [IsTextSelectionEnabled](# |
| static TemplateButtonCommandProperty | Property for [TemplateButtonCommand](# |
Methods¶
| Name | Summary |
|---|---|
| OnPropertyChanged | Called when a avalonia property changes on the object. |
| OnTextChanged | Called when text changes. |
| SetPlaceholderTextVisibility | Sets the placeholder text visibility. |
| OnGotFocus | Invoked 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. |
| OnLostFocus | Invoked 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. |
| RevealClearButton | Reveals the clear button by [ShowClearButton](# property. |
| HideClearButton | Hides the clear button by [ShowClearButton](# property. |
| OnClearButtonClick | Triggered when the user clicks the clear text button. |
| OnTemplateButtonClick | Triggered by clicking a button in the control template. |
| OnPlaceholderEnabledChanged | Called when placeholder enabled property changes. |