maui-devexpress-dot-maui-dot-editors-dot-texteditbase-83621c35.md
Gets or sets the text entered in the editor. This is a bindable property.
Namespace : DevExpress.Maui.Editors
Assembly : DevExpress.Maui.Editors.dll
NuGet Package : DevExpress.Maui.Editors
public string Text { get; set; }
| Type | Description |
|---|---|
| String |
The text entered in the editor.
|
Use the Text property to get or set text entered in the editor box.
Use the TextChangedCommand and TextChangedCommandParameter properties to specify the command executed when text changes. You can also handle the TextChanged event that fires when text changes.
After a user has finished the input and tapped the return button on the keyboard, the Completed event occurs.
To prevent users from entering text in the editor, set the IsReadOnly property to true.
Use the following properties to customize the text appearance and alignment:
This example shows how to change the input text color and adjust font settings:
<dxe:TextEdit Text="Input text"
TextColor="Blue"
TextFontAttributes="Italic"
TextFontSize="18"/>
To apply a custom font, add the font file to your solution, and then assign it to the editor’s TextFontFamily property.
This example shows how to apply the Verdana font.
Add the font file to your platform-specific projects:
In the App.xaml file, add the following lines to the ResourceDictionary section:
Set the TextFontFamily property to the key defined for the custom font:
Note
The TextFontAttributes property affects the default font only. If you need to apply a bold or an italic custom font, use the corresponding font style file as described above.
You can use the Text property to obtain the text entered in the editor and validate it.
This example shows how to validate the TextEdit‘s input text on a button tap. If no text is entered, the editor shows an error message.
<dxe:TextEdit x:Name="loginEditor"
ErrorText="Login cannot be empty!"/>
Subscribe to the button’s Clicked event.
In the event handler, set the editor’s HasError property to true if the Text string is null or empty.
Use the following properties to manage the cursor position and text selection:
|
Property
|
Description
| | --- | --- | |
|
Gets or sets the cursor position. This is a bindable property.
| |
|
Gets a character index at which the selection starts. This is a bindable property.
| |
|
Gets the number of selected characters. This is a bindable property.
|
You can also use the SelectAll(), SetSelection(Int32), and SetSelection(Int32, Int32) methods to select text.
An editor can display a ‘clear’ icon that allows users to remove text that was entered. Use the following properties to manage the ‘clear’ icon:
|
Property
|
Description
| | --- | --- | |
|
Gets or sets whether the clear icon is displayed. This is a bindable property.
| |
|
Gets or sets the clear icon image. This is a bindable property.
| |
ClearIconClicked
ClearIconCommand
|
Add a custom action to the ‘clear’ icon. Occurs when a user taps the clear icon.
| |
|
Gets or sets the color of the clear icon. This is a bindable property.
|
You can also optionally specify Prefix and Suffix that are shown before and after the input text (TextEdit), and add the following assistive text elements that provide additional information about text entered in the editor:
See Also