Discorver the First .NET MAUI (Release Candidate) Features!
Tags: csharp, dotnet, beginners, programming
Published: 2022-06-20 12:56:00

.NET MAUI is now a reality! After so many months of speculations, previews and rumors Microsoft officially launches the first Release Candidate of the cross-platform application development platform .NET MAUI!

As a spoiler, these new features are already available for the latest version of Microsoft’s IDE: **Visual Studio 2022** (although for the moment for Mac you will have to follow, according to Microsoft, the [command line instructions](https://github.com/dotnet/maui/wiki/macOS-Install)).

## Cross-Platform SDKs

This first Release Candidate of .NET MAUI includes [**cross-platform SDKs**](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1/#whats-in-the-net-maui-release-candidate) (Windows, iOs, Android and macOS). One of the main advantages of .NET MAUI is that these SDKs can be easily used with C#. This allows you to “_reuse_” code from other platforms (**cross-platform compatible code**) allowing you to get the most out of .NET MAUI.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gcr525a1n8fecnc3i2e6.png)
 

This is a big step forward because cross-platform application development will be much easier and more efficient (something I know many .NET developers were expecting from Microsoft).

## Layouts and Controls

Another new feature of [.NET MAUI Release Candidate 1](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1) is that Microsoft adds [**new layouts and controls**](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1/#whats-in-the-net-maui-release-candidate) (**more than _40_**). All these layouts and controls are prepared and optimized to be able to adapt to any type of user interface (both for mobile applications and desktop applications).

These more than 40 controls are mainly divided into **3 categories**:

-   [Pages](https://docs.microsoft.com/en-us/dotnet/maui/user-interface/controls/#pages)
-   [Layouts](https://docs.microsoft.com/en-us/dotnet/maui/user-interface/controls/#layouts)
-   [Views](https://docs.microsoft.com/en-us/dotnet/maui/user-interface/controls/#views)

The great thing about this is that in .NET MAUI, we will also have **all of the Xamarin.Forms UI controls.**

Another great advantage is that there is the possibility of **using blazor application components** to make an equal experience in web applications, desktop applications and mobile applications.

## New .NET MAUI Template

We are going to continue with new design features and this is a good one too.

Now Microsoft has decided to create a [**new .NET MAUI project template**](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1/#whats-in-the-net-maui-release-candidate). The improvement here is that now we will be able to **set the styles**, colors and color palettes we want in the default stylesheet `Resourcesstyles.xaml`. This way all the controls will load the styles that we are going to define in that style sheet.

Here is the [Microsoft example](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1/#whats-in-the-net-maui-release-candidate):

```csharp
<Style TargetType="Entry">
    <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
    <Setter Property="FontFamily" Value="OpenSansRegular"/>
    <Setter Property="FontSize" Value="14" />
    <Setter Property="PlaceholderColor" Value="{AppThemeBinding Light={StaticResource LightGray}, Dark={StaticResource DarkGray}}" />
    <Setter Property="VisualStateManager.VisualStateGroups">
        <VisualStateGroupList>
            <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal">
                    <VisualState.Setters>
                        <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="Disabled">
                    <VisualState.Setters>
                        <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource LightGray}, Dark={StaticResource DarkGray}}" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateGroupList>
    </Setter>
</Style>
```

This is a very good possibility if we don’t have the need for different platforms (desktop or mobile) to load different types of styles, this way it will always load the same style for all platforms sharing the theme.

## Customized controls

We continue with customization. Microsoft now adds the ability to [**modify controls explicitly on a particular platform**](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1/#customizing-controls). Using [_low-code hooks_](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1/#customizing-controls) we can explicitly set different conditions or styles for a specific platform that are different from the rest.

The [example shown by Microsoft](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1/#customizing-controls) is to remove the underline of an `Entry` field only on the Android mobile platform:

```csharp
#if ANDROID
Microsoft.Maui.Handlers.EntryHandler.Mapper.ModifyMapping("NoUnderline", (h, v) =>
{
    h.PlatformView.BackgroundTintList = ColorStateList.ValueOf(Colors.Transparent.ToPlatform());
});
#endif
```

The advantage of this is that the amount of code needed to customize the style of the controls is very small and only has to be executed at application startup time.

Microsoft leaves us [another more visual example](https://devblogs.microsoft.com/dotnet/dotnet-maui-rc-1/#customizing-controls):

```csharp
<Border Stroke="{StaticResource Black}"
        StrokeThickness="2"
        StrokeShape="Rectangle">
    <Entry
        Margin="20,4"
        Placeholder="Username" />
</Border>
```

The result:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tydakiakifzzsvlsj86i.png)
 


This will allow a great customization whatever the scenario and the platforms for which the application is developed.

I remind you that this is Release candidate 1 and that you can now officially use .NET MAUI (with official Microsoft support) to develop your cross-platform applications!