.NET MAUI Closer Than Ever (Discover +5 New Features)
Tags: csharp, dotnet, programming, news
Published: 2022-01-26 13:20:00

Just two months ago that, after many previews, pre-releases, leaks (and a lot of waiting) Microsoft **officially released the new version of its fastest full-stack web framework:** .NET 6. As many of us already know, Microsoft left out many of the features that came out in the Previews since, according to them, **they were not ready to be officially released.**

The response from the .NET developer community **has been super positive** despite not releasing all the promising features and functions. There is a small chance that **Microsoft expected a better response from the entire .NET developer community** and apparently **wants to fix this situation.**

We have just started the new year and Microsoft is getting serious: **Releases new Previews** of the long awaited **.NET MAUI.**

For those who don't know, **.NET MAUI is a cross-platform framework** ready to create all kinds of native mobile applications with C# and XAML. It allows you to develop applications for **iOS** and **macOS**, as well as for **Android** and **Windows**.

And at this point you may be wondering….

> Isn't Xamarin already there for mobile application development?

**Yes**, there is already Xamarin for that, but **Microsoft calls .NET MAUI as the "evolution" of Xamarin.**

> Like Pokemon?

Yes


![Source: https://www.pinterest.es/pin/770748923700305371/](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l359k2nx3q3r60c5edd5.gif)

To get into the topic, in the Previews released by Microsoft of .NET MAUI **some very interesting features are mentioned** - which hopefully, will be officially released. **So let's talk about them in depth!**

---

## Windows Control Styling (Fluent Design System)

Here, [David Ortinau](https://github.com/davidortinau) - The Principal Program Manager at .NET MAUI - tells us that they have **added design changes,** now with a **more fluid interface** and **new controls** and **support for themes.** The main updates are:

- [Button](https://github.com/dotnet/maui/pull/3363)
- [Editor](https://github.com/dotnet/maui/pull/3444)
- [Entry](https://github.com/dotnet/maui/pull/3444)


![source: https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-preview-11/](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q9wfmq00yox928e2plf0.png)

---

## Multi-window Apps

Here is one of the **most important** and main features of this Preview. Now with .NET MAUI **you can add multiple windows**. Simply with ``Application.Current.Windows`` you can **open a new window**, because it contains the references of the created windows.
Let's look at the [Microsoft example](https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-preview-11/#multi-window-apps):

```csharp
var secondWindow = new Window {
    Page = new MySecondPage {
        // ...
    }
};

Application.Current.OpenWindow(secondWindow);
```

![Source: https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-preview-11/](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zfblxx984l191xp318lx.png)

---

## Templates and C# 10

I think the phrase with which Microsoft introduces [this feature](https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-preview-11/#templates-and-c-10) is perfect:

> "Simplification is one of the main goals of .NET MAUI"

To do this, they have **added the templates using C# patterns,** both **file-scoped namespaces** and **implicit usings.** Besides, they have added new element templates, with which we (_the developers_) will save a lot of work. Let's see how it works (again I find the Microsoft example perfect):

```csharp
namespace Preview11;

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

        return builder.Build();
    }
}
```

At this point you will think:

> Where are the using statements?

Relax, don't worry - _**Microsoft says that**, not me._ From now on, with this new update **[implicit global usings](https://docs.microsoft.com/es-mx/dotnet/csharp/fundamentals/types/namespaces)** will be used to **gather them dynamically.**

---

## Shell and Dependency Injection

In this new feature Microsoft tells us a bit about ``HostBuilder``. With this, .NET MAUI will have a **powerful dependency injection**. What _Shell_ mainly offers is an **incredible templating and styling capability** to achieve in a very simple way our needs (or what we require at that moment).

To see it in a more practical way, let's look at [this example](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-12/#shell-and-dependency-injection):

As Microsoft tells us, we must define dependencies in the DI container.

```csharp
public static class MauiProgram
    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>();

            builder.Services
                .AddSingleton<MainViewModel>();

            return builder.Build();
        }
    }
```

And after that, we simply add in the page where we want the previously defined dependencies to be injected

```csharp
public partial class MainPage
{
    readonly MainViewModel _viewModel;

    public MainPage(MainViewModel viewModel)
    {
        InitializeComponent();

        BindingContext = _viewModel = viewModel;
    }
}
```

Very simple, right? Let's continue

---

## New Navigation in .NET MAUI (Shell)

What is this from Shell? Shell (also known as ``AppShell``) **facilitates simple application designs**, especially in **tabs and drop-down menus**.

Simply **add the pages to your app** and then **arrange them as you like** within the navigation structure. Let's see how nice it looks:


![Source: https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-12/](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqqsk6ovon9eproy95ts.png)

To be honest, I think **these new features are pretty cool**. Clearly considering that we've just started the year (and we've been looking forward to the release of .NET 6), Microsoft plans to **officially release .NET MAUI in Q2 2022**.

### And you, my dear reader?

- Do you think there will be more .NET MAUI Previews?
- What features would you like to see implemented?
- Do you think it will finally be true and will be officially 
- released this year?

Tell me in the comments, I would like to know more about it. You are always reading about me and what I write, now I want you to share with me what you think and I will gladly read and respond in the comments🤗