Skip to content

This repository contains a sample on How to validate all the editors of the Syncfusion Xamarin.Forms Dataform (SfDataform)?

Notifications You must be signed in to change notification settings

SyncfusionExamples/validate-all-editors-dataform-xamarin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to validate all the editors of Xamarin.Forms DataForm (SfDataform)

You can validate all the editors of Xamarin.Forms SfDataForm by using Validate method.

You can also refer the following article.

https://www.syncfusion.com/kb/11918/how-to-validate-all-the-editors-of-xamarin-forms-dataform-sfdataform

C#

You can validate all the properties using Validate inside the OnValidate command handler.

public DataFormViewModel()
{
    loginInfo = new DataFormModel();
    this.ValidateCommand = new Command<object>(this.OnValidate);
}
public Command<object> ValidateCommand { get; set; }
private void OnValidate(object dataForm)
{
    var dataFormLayout = dataForm as Syncfusion.XForms.DataForm.SfDataForm;
    dataFormLayout.Validate();
}

XMAL

ValidateCommand bind to Button form ViewModel

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="0.9*"/>
        <RowDefinition Height="0.1*"/>
    </Grid.RowDefinitions>
    <dataForm:SfDataForm x:Name="dataForm" DataObject="{Binding LoginInfo}" Grid.Row="0" ValidationMode="LostFocus" CommitMode="LostFocus"/>
    <Button x:Name="validateButton" Grid.Row="1"  Text="Submit" 
        Command="{Binding Path=BindingContext.ValidateCommand, 
        Source={x:Reference Name=dataForm}}"                                                   
        CommandParameter="{Binding Source={x:Reference Name=dataForm}}"/>
</Grid>

Output

ValidateAllDataForm

About

This repository contains a sample on How to validate all the editors of the Syncfusion Xamarin.Forms Dataform (SfDataform)?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages