Articles in this section

How to set a blank value to a picker editor in .NET MAUI DataForm?

In the Syncfusion® .NET MAUI DataForm (SfDataForm), you can set a blank value in a picker editor by utilizing custom data binding and source provisioning. Here's how you can achieve that with a simple example.

 

C#

 

Use the RegisterEditor method to associate the Picker Editor with specific properties in your form.

 

protected override void OnAttachedTo(ContentPage bindable)
{
    base.OnAttachedTo(bindable);
    this.dataForm = bindable.FindByName<SfDataForm>("dataForm");
    if (this.dataForm != null)
    {
        this.dataForm.ColumnCount = 2;
        this.dataForm.ItemsSourceProvider = new ItemSourceProvider();
        this.dataForm.RegisterEditor("From", DataFormEditorType.Picker);
        this.dataForm.RegisterEditor("To", DataFormEditorType.Picker);
        this.dataForm.RegisterEditor("PaymentMethod", DataFormEditorType.ComboBox);
    }
}

 

C#

 

Create a class that implements IDataFormSourceProvider, to supply data to the Picker editors, including a blank option.

 

class ItemSourceProvider : IDataFormSourceProvider
{
    public object GetSource(string sourceName)
    {
        if (sourceName == "From")
        {
            List<string> cityFrom = new List<string>() { " ", "Boston", "Los Vegas", "Chicago", "Portland" };
            return cityFrom;
        }
        if (sourceName == "To")
        {
            List<string> cityTo = new List<string>() { " ", "Los Angeles", "Seattle", "New York", "Denver" };
            return cityTo;
        }
 
        return new List<string>();
    }
}

 

Output:

Set a Blank Value to the Picker Editor in .NET MAUI DataForm

 

Conclusion:

 

I hope you enjoyed learning how to set a blank value to a Picker Editor in the .NET MAUI DataForm (SfDataForm).

 

You can refer to our .NET MAUI DataForm feature tour page to learn about its other groundbreaking feature representations. 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 comment 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