Featured image of post MAUI vs WPF

MAUI vs WPF

High Level Comparison

MAUI vs WPF

Ah, WPF. The granddaddy of .NET desktop development. If WPF was a house, it’d be a solid, well-built mansion from the early 2000s—reliable, but maybe a bit outdated.

Then comes .NET MAUI, a modern, multi-platform condo with all the fancy smart-home features.

So, which one should you use? Should you abandon WPF like an old VHS tape or embrace MAUI?


🧐 What Are These Two?

WPF – The Desktop Veteran

Windows Presentation Foundation (WPF) has been the go-to framework for Windows desktop applications since .NET 3.0.

It’s battle-tested, full of rich UI capabilities, and deeply integrated with Windows.

But here’s the catch: it’s Windows-only.

If your goal is cross-platform support, WPF is about as flexible as a brick.

MAUI – The Future of Multi-Platform UI

.NET MAUI (Multi-platform App UI) is Microsoft’s shiny new framework that lets you build applications for Windows, Mac, iOS, and Android—all from a single codebase.

While it originally evolved from Xamarin.Forms (which focused on mobileL(iPhone-Android)), MAUI extends its reach to desktops.


🔥 Key Differences

FeatureWPFMAUI
Supported PlatformsWindows onlyWindows, macOS, iOS, iPhone,Android
UI FrameworkXAML-basedXAML-based (but more flexible)
Graphics EngineDirectX-based renderingSkia/WinUI-based rendering
PerformanceOptimized for WindowsOptimized for cross-platform
Best Use CaseWindows desktop appsCross-platform apps (desktop + mobile)
Dependency on WindowsFullMinimal (Windows is just one platform)

🚀 Where MAUI Shines

  1. Cross-Platform Development
    WPF is great if you only care about Windows, but MAUI lets you target multiple platforms from one codebase.

  2. Modern UI Capabilities
    MAUI provides better UI flexibility, including handlers instead of the old renderer system from Xamarin.

  3. Performance Boosts
    With .NET 6/7 and beyond, MAUI optimizes performance better than older WPF applications.

  4. Better for Cloud-Connected and Mobile Apps
    If your app needs to be cloud-connected, responsive, and work across multiple platforms, MAUI is the way to go.


😰 Should You Migrate?

  • If your app is Windows-only and you don’t need cross-platform support, stick with WPF.
  • If you want future-proof, cross-platform development, MAUI is a better long-term bet.

WPF isn’t going away anytime soon, but Microsoft is heavily investing in MAUI, so if you’re starting fresh, you might want to go with MAUI.


🏗️ WPF vs MAUI – Class Equivalents

If you’re coming from WPF, you might be wondering: “Where did all my familiar classes go in MAUI?”
Don’t worry, here’s a cheat sheet to help you transition smoothly:

WPF ClassMAUI EquivalentDescription
WindowMauiApp & PageIn MAUI, there’s no direct Window class; instead, you structure your app using Pages.
ApplicationMauiApp & AppShellMauiApp is the new way to configure your app, and AppShell provides navigation.
UserControlContentViewIn MAUI, reusable components are ContentView instead of UserControl.
Grid, StackPanel, etc.Grid, StackLayout, FlexLayoutLayouts work similarly but have slight naming differences.
ButtonButtonButtons exist in both, but MAUI optimizes them for touch-based interfaces.
TextBlockLabelIn MAUI, Label is the primary way to display text.
ImageImageImage rendering remains mostly the same.
ListBox / DataGridCollectionView / ListViewMAUI uses CollectionView for more modern list-based UI.

As you can see, while WPF and MAUI have similarities, MAUI is more mobile-friendly and cross-platform-focused.


🆚 Code Comparison – WPF vs MAUI

1. Setting Up a Simple Window/Page

WPF (MainWindow.xaml & MainWindow.xaml.cs)

1
2
3
4
5
6
7
8
<Window x:Class="MyApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="WPF Window" Height="350" Width="525">
    <Grid>
        <TextBlock Text="Hello, WPF!" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Grid>
</Window>
1
2
3
4
5
6
7
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }
}

MAUI (MainPage.xaml & MainPage.xaml.cs)

1
2
3
4
5
6
7
8
9
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyApp.MainPage">
    <VerticalStackLayout>
        <Label Text="Hello, MAUI!" 
               VerticalOptions="Center" 
               HorizontalOptions="Center" />
    </VerticalStackLayout>
</ContentPage>
1
2
3
4
5
6
7
public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }
}

2. Handling Button Click Events

WPF (Button Click Event Handling)

1
<Button Content="Click Me" Click="Button_Click"/>
1
2
3
4
private void Button_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("Hello from WPF!");
}

MAUI (Button Click Event Handling)

1
<Button Text="Click Me" Clicked="OnButtonClicked"/>
1
2
3
4
private void OnButtonClicked(object sender, EventArgs e)
{
    DisplayAlert("Alert", "Hello from MAUI!", "OK");
}

Key Differences:

  • WPF uses MessageBox.Show(), while MAUI uses DisplayAlert().
  • MAUI’s Clicked event is the equivalent of WPF’s Click event.

🛠️ Visual Studio Setup – WPF vs MAUI

Setting Up a WPF Project

  1. Open Visual Studio (2022 recommended).
  2. Click Create a new project.
  3. Select WPF App (.NET 6/7).
  4. Configure your project name, location, and .NET version.
  5. Click Create, and you’re ready to start coding!

Setting Up a .NET MAUI Project

  1. Ensure Visual Studio 2022 (v17.3 or later) is installed.
  2. Open Visual Studio and go to Tools > Get Tools and Features.
  3. Install .NET Multi-platform App UI development under the Workloads tab.
  4. Click Create a new project, then choose .NET MAUI App.
  5. Configure your project name and location, then hit Create.

Key Differences:

  • WPF only requires the .NET desktop development workload, whereas MAUI requires the .NET Multi-platform App UI workload.
  • MAUI projects need extra setup for platform-specific configurations.

🤔 Key Ideas

  • WPF is a rock-solid choice for Windows-only applications.
  • MAUI is the future if you need cross-platform support.

If you’re happy with WPF and just building for Windows, stay put. But if you see a future where your app runs on macOS, mobile, and beyond, MAUI is worth the investment.



🛠️ Some Maui Frameworks to check out

  • MVVM for your .NET MAUI projects?: A

  • ReactiveUI: This is an advanced MVVM framework that integrates reactive programming principles B. It’s great for handling complex data flows and asynchronous operations B.

  • MVU (Model-View-Update): This is a variation of MVVM that focuses on a more functional programming approach B. It’s similar to React and can be a good choice if you’re familiar with those concepts B.

  • Prism: While it’s more commonly associated with WPF, Prism can also be used with MAUI for more advanced navigation and modularization A.

  • TinyMVVM: A lightweight MVVM framework that can be a good fit if you want something simpler and less boilerplate A.

  • Shield MVVM: This framework provides type safety and additional features for MAUI A.