Articles in this section

How to Validate All the Editors in .NET MAUI DataForm (SfDataForm)?

The Syncfusion® .NET MAUI DataForm provides a comprehensive solution for validating all editors using the Validate method. The ValidationMode can be set to determine when validation should occur, with Manual mode allowing for explicit validation by the user.

 

In Manual mode, you can trigger validation of all editors in the form with a button click. Here's how to configure this in your application. 

 

C#

Begin by setting up the DataForm and a button that will trigger the validation process.

protected override void OnAttachedTo(ContentPage bindable)
{
    base.OnAttachedTo(bindable);
    this.dataForm = bindable.FindByName<SfDataForm>("dataForm");
    if (dataForm != null)
    {
        dataForm.ItemsSourceProvider = new ItemSourceProvider();
        dataForm.RegisterEditor("Country", DataFormEditorType.AutoComplete);
        dataForm.RegisterEditor("City", DataFormEditorType.ComboBox);
    }
 
    this.validateButton = bindable.FindByName<Button>("validateButton");
    if (this.validateButton != null)
    {
        this.validateButton.Clicked += OnValidateClicked;
    }
}
private void OnValidateClicked(object sender, EventArgs e)
{
    dataForm.Validate();
}

 

Set the ValidationMode as Manual to the Dataorm and create a Button for validation.

 

XAML

<dataForm:SfDataForm x:Name="dataForm"
                     ValidationMode="Manual"
                     DataObject="{Binding DataFormModel}">
</dataForm:SfDataForm>

 

Download the complete sample on GitHub

 

Output:

 

Validate all the editors in .NET MAUI DataForm (SfDataForm)

 

Conclusion

I hope you enjoyed learning how to validate all the editors in .NET MAUI DataForm (SfDataForm).

 

Refer to our .NET MAUI DataForm feature tour page for its other groundbreaking feature representations. You can also explore our .NET MAUI DataForm documentation to understand how to present and manipulate data.

 

For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI DataForm and other .NET MAUI components.

 

Please let us know in the comments section if you have any queries or require clarification. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied