Back to Devexpress

Migrate from Xamarin.Forms to .NET MAUI

maui-403988-xamarin.md

latest24.5 KB
Original Source

Migrate from Xamarin.Forms to .NET MAUI

  • Jun 18, 2024
  • 6 minutes to read

.NET MAUI is an evolution of the Xamarin.Forms platform. Most DevExpress components for Xamarin.Forms have counterparts in .NET MAUI. If your Xamarin.Forms application is based on DevExpress components, you can follow the steps in this article to create a similar .NET MAUI application.

To migrate from the DevExpress Xamarin.Forms Controls to DevExpress .NET MAUI Controls, follow the steps below:

  1. Convert the projects from .NET Framework to .NET SDK Style
  2. Update NuGet packages
  3. Update code namespaces
  4. Address breaking API changes

View Example: Migrate a DevExpress Xamarin.Forms Application to .NET MAUI

See the following Microsoft topics for more information: Migrate your app from Xamarin.Forms and Xamarin.Forms Support Policy.

Step 1: Create a New Project

Refer to the following Microsoft topic for information on how to create a .NET MAUI project: Migrating from Xamarin.Forms - Create a New Project.

Step 2: Update DevExpress NuGet Package References

The following table lists DevExpress Xamarin.Forms NuGet packages and their equivalents in DevExpress .NET MAUI:

DevExpress Xamarin.Forms Controls NuGet PackageDevExpress .NET MAUI Controls NuGet Package
DevExpress.XamarinForms.ChartsDevExpress.Maui.Charts
DevExpress.XamarinForms.CollectionViewDevExpress.Maui.CollectionView
DevExpress.XamarinForms.EditorsDevExpress.Maui.Editors
DevExpress.XamarinForms.GridDevExpress.Maui.DataGrid
DevExpress.XamarinForms.NavigationDevExpress.Maui.Controls
DevExpress.XamarinForms.SchedulerDevExpress.Maui.Scheduler

Step 3: Update Code Namespaces

Step 3.1: Update Framework Namespaces

Refer to the following Microsoft topic for information on how to update framework namespaces: Migrating from Xamarin.Forms - Source Code Updates.

Step 3.2: Update DevExpress Namespaces

XAML Namespaces

The following table lists DevExpress Xamarin.Forms XAML namespaces and their equivalents in DevExpress .NET MAUI:

DevExpress Xamarin.Forms Controls NamespaceDevExpress .NET MAUI Controls Namespace
http://schemas.devexpress.com/xamarin/2014/forms/chartsclr-namespace:DevExpress.Maui.Charts;assembly=DevExpress.Maui.Charts
http://schemas.devexpress.com/xamarin/2014/forms/collectionviewclr-namespace:DevExpress.Maui.CollectionView;assembly=DevExpress.Maui.CollectionView
http://schemas.devexpress.com/xamarin/2014/forms/editorsclr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors
http://schemas.devexpress.com/xamarin/2014/forms/datagridclr-namespace:DevExpress.Maui.DataGrid;assembly=DevExpress.Maui.DataGrid
http://schemas.devexpress.com/xamarin/2014/forms/navigationclr-namespace:DevExpress.Maui.Controls;assembly=DevExpress.Maui.Controls
http://schemas.devexpress.com/xamarin/2014/forms/schedulerclr-namespace:DevExpress.Maui.Scheduler;assembly=DevExpress.Maui.Scheduler

Code-Behind Namespaces

The following table lists DevExpress Xamarin.Forms namespaces and their equivalents in DevExpress .NET MAUI:

DevExpress Xamarin.Forms Controls NamespaceDevExpress .NET MAUI Controls Namespace
DevExpress.XamarinForms.ChartsDevExpress.Maui.Charts
DevExpress.XamarinForms.CollectionViewDevExpress.Maui.CollectionView
DevExpress.XamarinForms.EditorsDevExpress.Maui.Editors
DevExpress.XamarinForms.GridDevExpress.Maui.DataGrid
DevExpress.XamarinForms.NavigationDevExpress.Maui.Controls
DevExpress.XamarinForms.SchedulerDevExpress.Maui.Scheduler

Step 3.3: Replace Initializers with the UseDevExpress Method

If you use DevExpress Xamarin.Forms Controls, your code calls the Initializer.Init() method for each DevExpress namespace you reference in the application:

csharp
using System.ComponentModel;
using Xamarin.Forms;
namespace DataGrid_Columns {
    public partial class MainPage : ContentPage {
        public MainPage() {
            DevExpress.XamarinForms.DataGrid.Initializer.Init();
            DevExpress.XamarinForms.Charts.Initializer.Init();
            // other DevExpress Xamarin.Forms Control Initializers
            InitializeComponent();
        }
    }
}

If you migrate to DevExpress .NET MAUI Controls , replace those method calls with a single call to the UseDevExpress(MauiAppBuilder, Boolean) method. It registers all DevExpress MAUI controls:

csharp
using DevExpress.Maui;

namespace DataForm_GettingStarted;
public static class MauiProgram {
    public static MauiApp CreateMauiApp() {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .UseDevExpress()
            .ConfigureFonts(fonts => {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            });
        return builder.Build();
    }
}

You can also pass true to the UseDevExpress() method as a parameter to localize DevExpress .NET MAUI Controls. Refer to the following topic for more information: Localization.

Step 3.4: Update the DevExpress Xamarin.Forms Types to Their .NET MAUI Equivalents

This section lists DevExpress Xamarin.Forms types that we renamed in DevExpress .NET MAUI. Rename the types in your applications and review related breaking API changes listed in footnotes.

Navigation

The table below lists types available in the DevExpress.XamarinForms.Navigation namespace and their .NET MAUI counterparts. Note that the types from the DevExpress.XamarinForms.Navigation namespace now belong to the DevExpress.Maui.Controls namespace.

Xamarin.Forms Type.NET MAUI Type
Navigation.ContentAlignmentControls.HeaderContentAlignment[1]
Navigation.HeaderElementsControls.HeaderElements
Navigation.ItemHeaderPlacementControls.ItemHeaderPlacement
Navigation.ItemHeaderTappedEventArgsControls.ItemHeaderTappedEventArgs
Navigation.PositionControls.HeaderContentPosition[1]
Navigation.TabHeaderUnitTypeControls.TabHeaderUnitType
Navigation.TabItemControls.TabItem
Navigation.TabItemLengthUnitTypeControls.TabItemLengthUnitType
Navigation.TabViewControls.TabView
Navigation.TabViewItemControls.TabViewItem
Related Breaking API Changes

Popup

The table below lists types available in the DevExpress.XamarinForms.Popup namespace and their .NET MAUI counterparts.

Note

All types from the DevExpress.XamarinForms.Popup namespace now belong to the DevExpress.Maui.Controls namespace.

Xamarin.Forms Type.NET MAUI Type
Popup.DXPopupControls.DXPopup
Popup.PlacementCore.Placement
Popup.PopupHorizontalAlignmentControls.PopupHorizontalAlignment
Popup.PopupVerticalAlignmentControls.PopupVerticalAlignment
Related Breaking API Change

Data Editors

The table below lists types available in the DevExpress.XamarinForms.Editors namespace and their .NET MAUI counterparts.

Note

Certain types from the DevExpress.XamarinForms.Editors namespace now belong to the DevExpress.Maui.Controls namespace.

Xamarin.Forms Type.NET MAUI Type
CalendarCellStyleCalendarCellAppearance[2]
CalendarDayCellStyleCalendarDayCellAppearance[2]
CalendarDayOfWeekCellStyleCalendarDayOfWeekCellAppearance[2]
CalendarHeaderStyleCalendarHeaderAppearance[2]
CalendarMonthCellStyleCalendarMonthCellAppearance[2]
CalendarSelectableCellStyleCalendarSelectableCellAppearance[2]
CalendarYearCellStyleCalendarYearCellAppearance[2]
Editors.CornerModeCore.CornerMode
CustomDayOfWeekCellStyleEventArgsCustomDayOfWeekCellAppearanceEventArgs[2]
CustomSelectableCellStyleEventArgsCustomSelectableCellAppearanceEventArgs[2]
Editors.FilterModeCore.DataFilterCondition[3]
Editors.IconHorizontalPositionControls.IconHorizontalPosition
Editors.IconVisibilityCore.IconVisibility
Editors.Localization.EditorsLocalizerEditors.EditorLocalizer[4]
Editors.SimpleButtonCore.DXButton
Related Breaking API Changes

Data Grid

The table below lists types available in the DevExpress.XamarinForms.DataGrid namespace and their .NET MAUI counterparts.

Xamarin.Forms Type.NET MAUI Type
CellStyleCellAppearance[2]
ColumnHeaderStyleColumnHeaderAppearance[2]
CustomCellStyleEventArgsCustomCellAppearanceEventArgs[2]
CustomSummaryProcessDataSummaryProcess[3]
DataGridValidationEventArgsValidateCellEventArgs[3]
GridColumnDataEventArgsCustomUnboundDataEventArgs[3]
GridLocalizerExtensionGridLocalizer[4]
GroupRowStyleGroupRowAppearance[2]
RowAllowEventArgsCancelRowEventArgs[3]
RowStyleBaseCellAppearanceBase[2]
StyleBaseAppearanceBase[2]
SummaryTypeDataSummaryType[3]
SwipeItemEventArgsSwipeItemShowingEventArgs[3]
SwipeItemStyleSwipeItemAppearance[2]
TotalSummaryStyleTotalSummaryAppearance[2]
Related Breaking API Changes

Charts

The table below lists types available in the DevExpress.XamarinForms.Charts namespace and their .NET MAUI counterparts.

Xamarin.Forms Type.NET MAUI Type
ChartBaseViewChartBaseView[5]
Related Breaking API Change

Scheduler

The table below lists types available in the DevExpress.XamarinForms.Scheduler namespace and their .NET MAUI counterparts.

Xamarin.Forms Type.NET MAUI Type
AllDayAreaCellStyleAllDayAreaCellAppearance[2]
AppointmentStyleAppointmentAppearance[2]
CellStyleSchedulerCellAppearance[2]
DayViewCellStyleDayViewCellAppearance[2]
DayViewHeaderItemStyleDayViewHeaderItemAppearance[2]
HeaderItemStyleHeaderItemAppearance[2]
ItemStyleAppearanceBase[2]
SchedulerLocalizerSchedulerLocalizer[4]
MonthViewCellStyleMonthViewCellAppearance[2]
MonthViewHeaderItemStyleMonthViewHeaderItemAppearance[2]
TextStyleMembers of this class and its descendants are now stored in the Appearance class of the Scheduler elements.[2]
TimeIndicatorStyleTimeIndicatorAppearance[2]
TimeRulerCellStyleTimeRulerCellAppearance[2]
TimeRulerHeaderStyleTimeRulerHeaderAppearance[2]
Related Breaking API Changes

Step 4: Address Breaking API Changes

To migrate your application from the DevExpress Xamarin.Forms Controls to DevExpress .NET MAUI Controls, you need to address the following breaking API changes:

Footnotes

  1. Breaking Change: T1125434 - Controls - API Changes

  2. Breaking Change: T1124204 - Changes on the Appearance Classes

  3. Breaking Change: T1120574 - DataGridView and DXCollectionView - API Changes

  4. Breaking Change: T1125921 - Localization Mechanism Changes

  5. Breaking Change: T1127009 - ChartViewBase.Theme Property Removed

See Also

Migrate your app from Xamarin.Forms

Xamarin.Forms Support Policy