.NET MAUI Embedding - GrapeCity ComponentOne .NET MAUI Controls
The FlexGrid and Calendar in the ComponentOne .NET MAUI Controls can be used in an Uno Platform application via .NET MAUI Embedding.
Sample App
An existing sample app that showcases the controls is available here.
Installation
In order to use the ComponentOne controls, you first need to install the ComponentOne ControlPanel following these instructions.
Getting Started
Create a new application using the
unoapp
template, enabling .NET MAUI Embedding. In this case, we're going to use the Blank template (-preset blank
) and include .NET MAUI Embedding support (-maui
).dotnet new unoapp -preset blank -maui -o MauiEmbeddingApp
Remove the
net7.0
target framework from both the MauiEmbeddingApp and MauiEmbeddingApp.MauiControls projects. GrapeCity doesn't provide reference assemblies fornet7.0
, so thenet7.0
target framework needs to be removed to avoid build errors.Next, add a reference to the C1 .NET MAUI NuGet packages to the MauiEmbeddingApp.MauiControls project. If you want to use the FlexGrid control, add a reference to
C1.Maui.Grid
. If you want to use the Calendar control, add a reference toC1.Maui.Calendar
.In the
AppBuilderExtensions
class, update theUseMauiControls
extension method to call either, or both, theRegisterFlexGridControls
orRegisterCalendarControls
methods.using C1.Maui.Grid; using C1.Maui.Calendar; namespace MauiEmbeddingApp; public static class AppBuilderExtensions { public static MauiAppBuilder UseMauiControls(this MauiAppBuilder builder) => builder .RegisterFlexGridControls() .RegisterCalendarControls() .ConfigureFonts(fonts => { fonts.AddFont("MauiEmbeddingApp/Assets/Fonts/OpenSansRegular.ttf", "OpenSansRegular"); fonts.AddFont("MauiEmbeddingApp/Assets/Fonts/OpenSansSemibold.ttf", "OpenSansSemibold"); }); }
Adding FlexGrid
Follow the FlexGrid Quick Start to apply XAML to the EmbeddedControl.xaml and C# code to the EmbeddedControl.xaml.cs (in the constructor).
Add Customer class (see https://www.grapecity.com/componentone/docs/maui/online-maui/customerclass.html).
Wrap content in
ScrollViewer
on theMainPage
of the Uno Platform application to make sure the fullFlexGrid
and other controls can be scrolled into the view.
App Render Output
Android:
Windows:
Adding Calendar
Follow the Calendar Quick Start to apply XAML to the EmbeddedControl.xaml.
In order for the Calendar control to render correctly on all platforms you should set both
HeightRequest
andWidthRequest
attributes on the Calendar control.
App Render Output
Android:
Windows: