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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to render DataForm using FSharp application in Xamarin.Forms?

Platform: Xamarin.Forms |
Control: SfDataForm |
Published Date: April 1, 2019 |
Last Revised Date: April 1, 2019
Tags: dataform, fsharp

This article explains how to render DataForm using FSharp application in Xamarin.Forms.

 

Define the properties in the model class.

 

   type ContactForm() =     
 
    member val Name = "John" with get,set
    member val Age= "20" with get,set
    member val Address = "" with get,set
    member val Email = "" with get,set 

 

In the main page, load the DataForm content in the FSharp project.

 

    type DataFormFSharp() = 
    inherit ContentPage()
 
    let _ = base.LoadFromXaml(typeof<DataFormFSharp>)    
    let dataForm = base.FindByName<SfDataForm>("dataForm")       
 
 
    type App() = 
    inherit Application(MainPage = DataFormFSharp()) 

 

Bind the view model to the ContentPage, and include DataForm inside a StackLayout. This is a function that takes the model and returns a UI based on the model.

 

    <ContentPage.BindingContext>
        <local:ViewModel></local:ViewModel>
    </ContentPage.BindingContext>
    <ContentPage.Content>
        <StackLayout Orientation="Vertical"
                     HorizontalOptions="FillAndExpand"
                     VerticalOptions="FillAndExpand">
            <dataForm:SfDataForm x:Name="dataForm"
                             VerticalOptions ="FillAndExpand"
                              DataObject="{Binding ContactInformation}"
                              BackgroundColor="White"
            </dataForm:SfDataForm>
        </StackLayout>
    </ContentPage.Content>

 

Set the ContactForm model class in the view model class of the application.

 

type ViewModel() =     

    member val ContactInformation = ContactForm() with get, set
 
 

 

Sample Demo: DataFormFSharp

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