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
Feature | WPF | MAUI |
---|---|---|
Supported Platforms | Windows only | Windows, macOS, iOS, iPhone,Android |
UI Framework | XAML-based | XAML-based (but more flexible) |
Graphics Engine | DirectX-based rendering | Skia/WinUI-based rendering |
Performance | Optimized for Windows | Optimized for cross-platform |
Best Use Case | Windows desktop apps | Cross-platform apps (desktop + mobile) |
Dependency on Windows | Full | Minimal (Windows is just one platform) |
🚀 Where MAUI Shines
Cross-Platform Development
WPF is great if you only care about Windows, but MAUI lets you target multiple platforms from one codebase.Modern UI Capabilities
MAUI provides better UI flexibility, including handlers instead of the old renderer system from Xamarin.Performance Boosts
With .NET 6/7 and beyond, MAUI optimizes performance better than older WPF applications.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 Class | MAUI Equivalent | Description |
---|---|---|
Window | MauiApp & Page | In MAUI, there’s no direct Window class; instead, you structure your app using Pages . |
Application | MauiApp & AppShell | MauiApp is the new way to configure your app, and AppShell provides navigation. |
UserControl | ContentView | In MAUI, reusable components are ContentView instead of UserControl . |
Grid , StackPanel , etc. | Grid , StackLayout , FlexLayout | Layouts work similarly but have slight naming differences. |
Button | Button | Buttons exist in both, but MAUI optimizes them for touch-based interfaces. |
TextBlock | Label | In MAUI, Label is the primary way to display text. |
Image | Image | Image rendering remains mostly the same. |
ListBox / DataGrid | CollectionView / ListView | MAUI 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)
|
|
|
|
MAUI (MainPage.xaml & MainPage.xaml.cs)
|
|
|
|
2. Handling Button Click Events
WPF (Button Click Event Handling)
|
|
|
|
MAUI (Button Click Event Handling)
|
|
|
|
Key Differences:
- WPF uses
MessageBox.Show()
, while MAUI usesDisplayAlert()
. - MAUI’s
Clicked
event is the equivalent of WPF’sClick
event.
🛠️ Visual Studio Setup – WPF vs MAUI
Setting Up a WPF Project
- Open Visual Studio (2022 recommended).
- Click Create a new project.
- Select WPF App (.NET 6/7).
- Configure your project name, location, and .NET version.
- Click Create, and you’re ready to start coding!
Setting Up a .NET MAUI Project
- Ensure Visual Studio 2022 (v17.3 or later) is installed.
- Open Visual Studio and go to Tools > Get Tools and Features.
- Install .NET Multi-platform App UI development under the Workloads tab.
- Click Create a new project, then choose .NET MAUI App.
- 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.
🔗 Reference Links
- Microsoft’s Official .NET MAUI Documentation
- WPF Documentation
- Choosing Between WPF and MAUI
- Getting Started with .NET MAUI
🛠️ 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.