)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load the picker editor ItemsSource from SQLite offline database in Xamarin.Forms DataForm?

Platform: Xamarin.Forms |
Control: SfDataForm |
Published Date: November 15, 2018 |
Last Revised Date: November 15, 2018

DataForm allows you to load the picker editor ItemsSource from local database using SQLite. To achieve this, follow the steps:

 

  1. Add the database to the cross-platform projects Resource folder.

 

Refer to the following link to know how to create SQLite connection:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/databases

 

  1. Create a connection with the database using interface in cross platform projects and create an interface in PCL project.

 

 

  1. Create a class inherited from the ISQLite interface in cross-platform project and get connection with the offline database.

 

In Android cross-platform project,

 

 

In iOS cross-platform project,

 

 

In UWP cross-platform project,

 

 

  1. Create a model of DataForm. Here, the City property is used as picker editor.

 

 

Refer to the following code example for binding the DataObject and register the editor as Picker for the property City using RegisterEditor in DataForm.

 

https://help.syncfusion.com/xamarin/sfdataform/editors#customizing-itemssource-of-picker

 

 

  1. Initialize a database using SQLiteConnection to create table for storing data form items (other than picker) and insert the data form items (other than picker) and values in database table.

 

 

Get the database table data in DataForm when setting the DataObject.

 

 

Create a class to get the picker item in database.

 

 

 

  1. Initialize a separate database using SQLiteConnection to create a table for storing the data form picker items and insert the picker item value in table.

 

  1. Get the picker database table items as IEnumerable for picker editor in data form by setting the ItemSource of DataFormPickerItem in the AutoGeneratingDataFormItem event.

 

To display complex type property as picker (other than enum data type), refer to the user guide documentation.

 

https://help.syncfusion.com/xamarin/sfdataform/editors#loading-complex-type-property-values-in-picker

 

 


Note:

Picker editor is not supported in Xamarin.Forms.UWP platform.

 

You can refer to the DataForm user guide documentation to learn more about picker:

https://help.syncfusion.com/xamarin/sfdataform/editors#picker-editor

 

To download sample click PickerItemsFromSQLite.

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon