Skip to main content

BaseEdit.ValidateOnTextInput Property

Gets or sets whether the edit value should be validated while typing within the editor’s text box. This is a dependency property.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v24.1.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public bool ValidateOnTextInput { get; set; }

Property Value

Type Description
Boolean

true to validate the edit value while an end-user types text within the editor’s text box; otherwise, false.

Remarks

If the ValidateOnTextInput property is set to true and an end-user changes text within the editor, the editor fires the BaseEdit.Validate event on each change, allowing you to validate a new value. Otherwise, the text entered by the end-user is validated and posted to BaseEdit.EditValue after the ENTER key has been pressed (if the BaseEdit.ValidateOnEnterKeyPressed property is set to true) or the editor has lost the focus. In this instance, to obtain the text entered by the end-user, do the following:

private void Window_Loaded(object sender, RoutedEventArgs e) {
    ((TextBox)textedit1.EditCore).AddHandler(TextBox.TextInputEvent, 
        new TextCompositionEventHandler(MainWindow_PreviewTextInput), true);
}

void MainWindow_PreviewTextInput(object sender, TextCompositionEventArgs e) {
    textblock1.Text = ((TextBox)textedit1.EditCore).Text;
}

The BaseEdit.Validate event isn’t raised if the editor’s BaseEdit.CausesValidation property is set to false.

To specify whether the editor’s value should be validated after the ENTER key has been pressed, use the BaseEdit.ValidateOnEnterKeyPressed property.

If the ValidateOnTextInput property is set to false, the WPF validation mechanism is used. In this instance, to avoid invalid values from posting to a data source, the BaseEdit.EditValue, TextEditBase.Text and BaseEdit.DisplayText properties are synchronized with the text entered by the end-user only after this text is validated.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ValidateOnTextInput property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also