Articles in this section
Category / Section

How to render DataForm using ReactiveUI in Xamarin Forms?

1 min read

ReactiveUI is built on a reactive programming foundation and is specifically implemented utilizing Reactive Extensions. This article explains how to render Xamarin.Forms dataform in ReactiveUI framework in Xamarin Forms.

XAML

DataForm definition in xaml.

<Grid>
    <dataForm:SfDataForm x:Name="dataForm" Grid.Row="0"/>
</Grid>

C#

The ContactInfo class (ViewModel) should be inherited from ReactiveObject.

    public class ContactInfo : ReactiveObject
    {
        private AddressInfo addressInfo;
        public AddressInfo AddressInfo
        {
            get => addressInfo;
            set => this.RaiseAndSetIfChanged(ref addressInfo, value);
        }
        public ContactInfo()
        {
            AddressInfo = new AddressInfo();
        }
    }
 
    public class AddressInfo
    {
        public string Name { get; set; }
        public string Address{ get; set; }
        public string Email { get; set; }
        public string City { get; set; }
    }

C#

Derive the MainPage from IViewFor<T>, implement this interface on your Views to support Routing and Binding, and then set up the bindings for DataObject in the main page for the defined view model.

    public partial class MainPage : ContentPage, IViewFor<ContactInfo>
    {
        public MainPage()
        {
            InitializeComponent();
            ViewModel = new ContactInfo();
            this.Bind(ViewModel, x => x.AddressInfo, x => x.dataForm.DataObject);
        }
 
        public ContactInfo ViewModel { get; set; }
        object IViewFor.ViewModel
        {
            get { return ViewModel; }
            set { ViewModel = (ContactInfo)value; }
        }
    }

Output

gif

View sample in GitHub


Conclusion

I hope you enjoyed learning how to render DataForm using ReactiveUI in Xamarin.Forms.

You can refer to our Xamarin DataForms feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Xamarin dataForms example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-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)
Please sign in to leave a comment
Access denied
Access denied