Articles in this section

How to integrate .NET MAUI DataForm with Android native embedding application?

This article guides you through creating a .NET MAUI DataForm native embedded Android application by following the step-by-step process explained as follows.

Step 1:
Create a .NET Android application and install the Syncfusion.Maui.DataForm NuGet package using the nuget.org.

Step 2:
In the project file of the native application, add <UseMaui>true</UseMaui> to enable the .NET MAUI support.

<PropertyGroup>
   <Nullable>enable</Nullable>
   <ImplicitUsings>enable</ImplicitUsings>
   <UseMaui>true</UseMaui>
</PropertyGroup>

Step 3:
Creating a MauiAppBuilder object and using the UseMauiEmbedding function is the standard procedure for initializing .NET MAUI in a native app project.

Build a MauiApp object using the Build() method and create a MauiContext from it. This context will be used for converting .NET MAUI controls to native types.

MauiContext? _mauiContext;
protected override void OnCreate(Bundle? savedInstanceState)
{
   base.OnCreate(savedInstanceState);
   MauiAppBuilder builder = MauiApp.CreateBuilder();
   builder.UseMauiEmbedding<Microsoft.Maui.Controls.Application>();
   builder.ConfigureSyncfusionCore();
   MauiApp mauiApp = builder.Build();
   _mauiContext = new MauiContext(mauiApp.Services, this);
}

Step 4:

Define a model class to specify the data object with the required properties.

public class DataFormModel
{
   public string FirstName { get; set; }

   public string MiddleName { get; set; }

   public string LastName { get; set; }

   public string ContactNumber { get; set; }

   public string Email { get; set; }

   public string Address { get; set; }

   public DateTime? BirthDate { get; set; }

   public string GroupName { get; set; }
}

Step 5:

Initialize the SfDataForm control with the DataFormModel as the data object.

protected override void OnCreate(Bundle? savedInstanceState)
{
   ...
   SfDataForm dataForm = new SfDataForm()
   {
       DataObject = new DataFormModel()
   };
   ...
}

Step 6:

Convert the DataForm control to a platform-specific view for the MAUI framework and set this view as the content view for the current Android activity.

protected override void OnCreate(Bundle? savedInstanceState)
{
   ...
   Android.Views.View view = dataForm.ToPlatform(_mauiContext);

   // Set your view from the "main" layout resource.
   SetContentView(view);
}

Download the complete sample from GitHub.

Output:

DataForm.png

Conclusion:
I hope you enjoyed learning how to integrate Android Native embedding for the .NET MAUI DataForm.

You can refer to our .NET MAUI DataForm feature tour page to learn about its other groundbreaking feature representations. You can also explore our .NET MAUI DataForm documentation to understand how to present and manipulate data.

For current customers, you can check out our .NET MAUI 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.

If you have any queries or require clarification, please let us know in the comments section below. You can also 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