New to Telerik UI for .NET MAUI? Start a free 30-day trial

Validation

.NET MAUI DataForm provides built-in validation, which gives you full control over the data collected through the control.

The next sections list all DataForm members related to validation.

Validation modes

The selected mode is applied through ValidationMode(of typeTelerik.Maui.Controls.DataFormValidationMode) property of the DataForm control. You could choose between three validation modes:

  • Explicit—The changes are validated explicitly by invoking the ValidateCommand or calling the ValidateChanges method of the DataForm.
  • LostFocus—The changes are validates after the editor loses focus.
  • PropertyChanged—The changes in the editor are validated immediately on each property change (when the property value changes).

The ValidationMode can be applied globally to the RadDataForm

<telerik:RadDataForm x:Name="dataForm"
                     ValidationMode="LostFocus"/>

or to each editor.

<telerik:RadDataForm x:Name="dataForm" AutoGenerateItems="False">
    <telerik:DataFormTextEntry PropertyName="FirstName" HeaderText="Name" ValidationMode="LostFocus"/>
    <telerik:DataFormNumericEditor PropertyName="People" HeaderText="People" Minimum="1" ValidationMode="PropertyChanged"/>
</telerik:RadDataForm>

Methods

  • ValidateChanges—Executes the validation logic associated with the DataForm control. This method is mostly useful when the ValidationMode is set to `Explicit. The method returns true if the validation passes, otherwise false.

Commands

  • ValidateCommand(ICommand)—Gets a command to execute the validation logic of the RadDataForm. This command is mostly useful when the DataForm ValidationMode property is set to Explicit.

Validation message - styling and customization

You can use the following properties for validation styling and customization:

  • ValidationSummaryImageSource(ImageSource)—Specifies the ImageSource of the image displayed in the validation summary.
  • ValidationSummaryImageStyle(Style)—Specifies the style applied to the image of the validationsummary. The target type of this style is the .NET MAUI Image control.
  • ValidationSummaryStyle(Style)—Specifies the style applied to the validation summary. The target type of this style is the Telerik.Maui.Controls.DataFormValidationSummaryView.
  • ValidationSummaryLabelStyle(Style)—Specifies the style applied to the labels of the validation summary. The target type of this style is the .NET MAUI Label control.

Error message - styling and customization

You can use the following properties for error message styling and customization:

  • ErrorImageSource(ImageSource)—Specifies the ImageSource of the image displayed in the error message.
  • ErrorImageStyle(Style)—Specifies the style applied to the image of the error message. The target type of this style is the .NET MAUI Image control.
  • ErrorLabelStyle(Style)—Specifies the style applied to the labels of the error message. The target type of this style is the .NET MAUI Label control.

See Also

In this article
Not finding the help you need?