DataForm for Xamarin.iOS: Getting Started
This quick start tutorial demonstrates how you can add TKDataForm
to your Xamarin.iOS application.
Setting up TKDataForm
There are two approaches you can use - either add a TKDataForm
instance to an existing UIViewController or utilize our predefined TKDataFormViewController
.
Either way you choose, first you will need to reference Telerik.Xamarin.iOS.dll into the Xamarin.iOS project.
Adding TKDataForm instance
Open your UIViewController file and add a reference to the TelerikUI
namespace:
You should create a business object that will be displayed and edited by TKDataForm
. Let's create a class called PersonalInfo
:
The TKDataForm
object should be created in ViewDidLoad
method of the UIViewController:
And here is the result:
Utilizing TKDataFormViewController
The other option is to utilize the TKDataFormViewController
- it inherits from UIViewController
and contains a predefined TKDataForm
instance.
For the example below the same PersonalInfo
class is used as a source of the DataForm.
Customize the editors
TKDataForm chooses a default editor based on each property's type. You have the option to change the default editors by utilizing the TKDataFormEntityDataSourceHelper
class and set it as the DataSource of the DataForm. TKDataFormEntityDataSourceHelper
gives access to each dataform entity for each property of the source object, so you can modify its editor, provide predefined values, and more.
In addition, if you would like to customize the editors, you would need to adopt TKDataFormDelegate
and override its UpdateEditor
method. Then you just need to set thus created delegate to the Delegate
property of the TKDataForm instance.
Check below an example of TKDataFormEntityDataSourceHelper
and TKDataFormDelegate
:
where MydDataFormDelegate is defined as below:
The images below show the result after applying the snippet:
![]() |
![]() |