Introducing .NET Multi-platform App UI

Scott Hunter [MSFT]

Scott

You can build anything with .NET. It’s one of the main reasons millions of developers choose .NET as the platform for their careers, and companies invest for their businesses. With .NET 5 we begin our journey of unifying the .NET platform, bringing .NET Core and Mono/Xamarin together in one base class library (BCL) and toolchain (SDK).

As we consider what building device applications will look like in a unified .NET, we see many devices across multiple platforms used, from Android and iOS to Windows and macOS. To address this need we are excited to announce a new first-class UI framework for doing just that: .NET Multi-platform App UI, affectionately called .NET MAUI.

Let us introduce you to what .NET MAUI is, the single project developer experience, modern development patterns, and a look at the journey ahead.

MAUI overview

What is .NET MAUI

.NET MAUI is an evolution of the increasingly popular Xamarin.Forms toolkit that turns 6 years old this month. For years companies such as UPS, Ernst & Young, and Delta have been leveraging the mobile expertise of Xamarin atop .NET to power their businesses; some since the very beginning. It has also been very successful in helping small businesses maximize their development investment sharing upwards of 95% of their code, and beating their competitors to market. .NET MAUI extends this success on mobile to embrace the desktop making it the best way to build multi-platform applications across both, especially our new devices such as the new Surface Duo.

.NET MAUI simplifies the choices for .NET developers, providing a single stack that supports all modern workloads: Android, iOS, macOS, and Windows. The native features of each platform and UI control are within reach in a simple, cross-platform API for you to deliver no-compromise user experiences while sharing even more code than before.

Single Project Developer Experience

.NET MAUI is built with developer productivity in mind, including the project system and cross-platform tooling that developers need. .NET MAUI simplifies the project structure into a single project to target multiple platforms. This means you can easily deploy to any target that you wish including your desktop, emulators, simulators, or physical devices with a single click. With built-in cross-platform resources you will be able to add any images, fonts, or translation files into the single project, and .NET MAUI will automatically setup native hooks so you can just code. Finally, you will always have access the native underlying operating system APIs and it will be easier than ever with new platform specific integrations. Under platforms you can add source code files for a specific operating system and access the native APIs. With .NET MAUI everything is in one place where you need it to keep you productive.

.NET MAUI Single Project

This delivers:

  • One project targeting multiple platforms and devices
  • One location to manage resources such as fonts and images
  • Multi-targeting to organize your platform-specific code

You master one way to build client apps, the .NET MAUI way, and all platforms are within your reach. Today, Scott Hanselman and I will demo it in action at Build, The Journey to One .NET.

Modern App Patterns

Part of the vision for one .NET is providing developer choice in the areas of personal preferences so you can be most productive using .NET. This manifests in which IDE you use whether Visual Studio 2019, Visual Studio for Mac, or even Visual Studio Code. .NET MAUI will be available in all of those, and support both the existing MVVM and XAML patterns as well as future capabilities like Model-View-Update (MVU) with C#, or even Blazor.

MVVM

Model-View-ViewModel (MVVM) and XAML, the predominant pattern and practice among .NET developers for decades now, are first-class features in .NET MAUI. This will continue to grow and evolve to help make you productive building and maintaining production apps.

<StackLayout>
    <Label Text="Welcome to .NET MAUI!" />
    <Button Text="{Binding Text}" 
            Command="{Binding ClickCommand}" />
</StackLayout>
public Command ClickCommand { get; }

public string Text { get; set; } = "Click me";

int count = 0;

void ExecuteClickCommand ()
{
    count++;
    Text = $"You clicked {count} times.";
}

MVU

In addition, we are enabling developers to write fluent C# UI and implement the increasingly popular Model-View-Update (MVU) pattern. MVU promotes a one-way flow of data and state management, as well as a code-first development experience that rapidly updates the UI by applying only the changes necessary. For more information about MVU as a pattern, check out this Elm Programming guide and this blog from Thomas Bandt.

Below is a basic counter example in the MVU style written in .NET MAUI.

readonly State<int> count = 0;

[Body]
View body() => new StackLayout
{
    new Label("Welcome to .NET MAUI!"),
    new Button(
        () => $"You clicked {count} times.",
        () => count.Value ++)
    )
};

This pattern is ideally suited for hot reload as you can see below with added styling, gradients, and fonts with instant hot reload from C#.

MAUI model-view-update

Both MVVM and MVU deliver the same native applications, performance, and platform fidelity. Developers will be able to choose which style best suits their preference and use case.

Transitioning from Xamarin.Forms to .NET MAUI

Xamarin.Forms developers will hit the ground running with new projects in .NET MAUI, using all the same controls and APIs they have grown to know and love. As we get closer to the .NET MAUI launch, In order to help developers make a smooth transition of existing apps to .NET MAUI we intend to provide try-convert support and migration guides similar to what we have today for migrating to .NET Core.

The .NET MAUI Timeline

We will begin shipping .NET MAUI previews later this year, and target general availability with .NET 6 in November of 2021. .NET MAUI will ship on the same 6 week cadence that Xamarin.Forms has been on. We have published the .NET MAUI roadmap on GitHub and invite you to join us there today!

What’s Next for Xamarin and Xamarin.Forms

As part of our .NET unification, Xamarin.iOS and Xamarin.Android will become part of .NET 6 as .NET for iOS and .NET for Android. Because these bindings are projections of the SDKs shipped from Apple and Google, nothing changes there, however build tooling, target framework monikers, and runtime framework monikers will be updated to match all other .NET 6 workloads. Our commitment to keeping .NET developers up-to-date with the latest mobile SDKs is foundational to .NET MAUI and remains firm. When .NET 6 ships, we expect to ship a final release of Xamarin SDKs in their current form that will be serviced for a year. All modern work will at that time shift to .NET 6.

Xamarin.Forms will ship a new major version later this year, and continue to ship minor and service releases every 6 weeks through .NET 6 GA in November 2021. The final release of Xamarin.Forms will be serviced for a year after shipping, and all modern work will shift to .NET MAUI.

Get Involved Today

Join us on this journey to .NET MAUI at our brand new repository dotnet/maui. Be sure to star and watch to get notifications, then join in the discussion of proposals describing how we want to evolve the code base. This is the very beginning of a long journey welding Xamarin and Xamarin.Forms directly into the heart of .NET, and we are excited to do this in the open with you.

165 comments

Comments are closed. Login to edit/delete your existing comments

  • Mahdi Safarmohammadloo
    Mahdi Safarmohammadloo

    Where is the WEB SUPPORT ? (webassembly)
    blazor is not like flutter and maui , and its not good option for single code bases.

  • Avatar
    震淼 韩

    Is Microsoft365 will development on MAUI?
    It will be a excellent news to .Net and MAUI coders if Microsoft365 develpoed on MAUI.

  • Avatar
    Indudhar Gowda

    This is Super Stuff…Good Bye Java, Swift.

    Looks like .NET MAUI will put a full stop to all other Language..

    1. Hot Reload working on XAML and C# will Definitely help in building the Apps Faster. Can we take this Feature to Blazor, UWP, and WPF where c# reload is Missing.

    2. Can we bring Live Visual Tree to Blazor , .NET MAUI or Xamarin.

    3. Can we bring INotification PropertyChange to Blazor.

  • Avatar
    Farr, Derek

    What version of XAML will be in MAUI?
    (Personal preference…please, please, PLEASE let it be WPF/WinUI’s version. XF XAML has many confusing patterns and names. KISS!!!!)

    Is Height going to be Height and no longer need to use HeightRequest?

  • Avatar
    Eduard Kagan

    What we really need is Blazor Native to replace all this nonsense 😀

    • Avatar
      Rod Macdonald

      I’d say WinUI with fluent compatibility for Blazor Native is all we need. The former for the Windows platform, the latter for cross platform + fluent hook up on Windows. Job done.

      Maui is one of those endless goals that frustrate us all. You see the blip on the horizon then it disappears and all your aspirations sink…

  • Avatar
    devtommy

    Will be MAUI(WinUI) and Blazor unified?
    Two different UI for the Web and another for the others(iOS, Android, Mac, Windows) will be bad again.

  • Avatar
    Stefan Tsalapatis

    Your efforts are excellent. But I would propose (as a priority) another project, a way to link C# libraries to Dart.

        • Avatar
          saint4eva

          I think the .NET/ Xamarin would want to put in all the energy making this UI a great platform than developing a binding for flutter. However, it would be a great community-championed project.

          • Avatar
            Stefan Tsalapatis

            Finding a way to link C# libraries to Dart, it is not community-championed project.
            It should be a project of Microsoft’s primary interest, if MS does not want to lose C# developers.
            What would happen after 2 years, with this proposed UI, it is something beyond our interest, right now. I wish the best.

  • Jeff Johnson
    Jeff Johnson

    Really hoping you manage to knock the four remaining files out for single file on windows. Need a way to have the exe stand alone. Even if those files have to be extracted to the same folder or a temp folder at runtime that’s fine. Just don’t require them in the folder when the exe is run please.

  • Avatar
    Jeff Siemens

    Wow, this was a unexpected surprise! Overall, I am very excited about what I see!

    In particular, I’d like to give two very enthusiastic thumbs up to:

    • One .NET – integrating Xamarin right into .NET
    • Simplified project files
    • Support for both VS and VS Code
    • A single project that you can run on Windows, iOS, or Android! This truly blew my mind
    • Commitment to multi-platform app development using .NET
    • Support for both MVVM and MVU – cool!
    • Hot reload / hot restart built in from the start. I just hope that it works better than hot reload, because despite the claims from Xamarin that it will work in complex projects, it doesn’t
    • Ability to deploy to an iOS device straight from Windows! Not sure how you guys pulled this off! Again, mind blown!

    Overall, really great stuff!

    Now for some constructive feedback…

    • I happened to notice that you used a “NavigationView” (not Page). This actually got me excited. Now, I’m reading behind the lines a little here, and hoping (really hoping) that this means that you can embed it inside another view. Now, wishful thinking, but I’m also really hoping you guys ditch the whole Page architecture in Xamarin Forms altogether. It’s infuriatingly inflexible. I just want to be able to nest anything inside of anything. Yes, it’s actually important to be able to put a NavigationView inside of a stack. So don’t make it a Page! Don’t make anything a Page! Well, you can have one Page – ContentPage and that’s it. It’s your top level construct for your app, and everything else should be a View.
    • Please support svg/xml/pdf icons and make them tintable. And if you’re thinking of fonts as the answer for vectorization – I issue this warning: fonts aren’t good enough, because you can’t just add a single item to a font. We have a graphics department that makes icons. We have an extensibility mechanism that allows for 3rd parties to bundle their own icons into our app. So fonts don’t work – you can’t add to them. And please please discourage people as much as possible from using Pngs. Pngs should be burned to the ground. They’re not scaleable. They’re not vector. It’s an absolute maintenance nightmare to try to maintain Pngs. Please don’t use Pngs.
    • Please support a wide variety of mobile controls – ideally, looking to match the first party controls from UWP / WinUI, iOS, and Android
    • Please focus on startup and rendering performance
    • Please do ListView / CollectionView, whatever you want to call it, right
    • For the same reason that Pages are horrible and inflexible, please burn Shell to the ground – rigid, inflexible, and useless outside of a horrendously simple demo app. Just make a FlyoutView and a TabView, and you’ve got everything that Shell offers but with way more flexibility.
    • Please do safe areas right. And don’t just put a 30pt margin at the top and a 20pt margin at the bottom (or whatever the dimensions of the notches are on your phone). We actually want stuff to go outside of the safe area too!

    Anyways, I’m really excited about what I see. I hope someone at Microsoft reads this and listens to my feedback.

    Feel free to reach out to me if you want to discuss any of these ideas with me. I’d be happy to!

    Basically it all comes down to this – if you can enable developers to build the types of apps that people with native frameworks, but in a cross platform way, and without having to bend over backwards to avoid the limitations of your platform, then it will be a huge success. That is the litmus test. From what I’ve seen so far, I really believe this is achievable.