Articles in this section

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.

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

A screenshot of a cell phone

Description automatically generated

View sample in GitHub

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