DEV Community

Cover image for 4 Impressive Features of .NET MAUI in .NET 7
Jollen Moyani for Syncfusion, Inc.

Posted on • Originally published at syncfusion.com on

4 Impressive Features of .NET MAUI in .NET 7

The .NET Multi-platform App UI (.NET MAUI) is a cross-platform framework that helps developers create native mobile and desktop apps with C# and XAML. It’s the latest evolution of Xamarin.Forms. As you (probably) know, .NET MAUI is now available for .NET 7. I was really surprised to get this update so soon, with more features and performance improvements no less.

In this blog, I will take you through the new features of .NET MAUI for .NET 7.0 that excited me, and I recommend that you try them:

.NET MAUI context menu

You can now enjoy context menu support in .NET MAUI as part of the .NET 7 release. This feature is mainly aimed at desktop platforms. You can easily integrate it from the FlyoutBase class with any BindableObject (e.g., a label).

<Label Text="Right-click here to show Context Menu">
 <FlyoutBase.ContextFlyout>
  <MenuFlyout>
   <MenuFlyoutItem Text="Cut" />
   <MenuFlyoutItem Text="Copy"/>
   <MenuFlyoutItem Text="Paste"/>
  </MenuFlyout>
 </FlyoutBase.ContextFlyout>
</Label>
Enter fullscreen mode Exit fullscreen mode

Context Menu Support for .NET MAUI in .NET 7.0

Context Menu Support for .NET MAUI in .NET 7.0

Tooltip support

Tooltip support was one of the most wanted features in .NET MAUI, and that feature is now included. With it, you can add a tooltip to any visual element by using the ToolTipProperties.Text (attached property).

Refer to the following code example.

<Label ToolTipProperties.Text="Hello!"
       Text="Hover on me to show tooltip">
</Label>
Enter fullscreen mode Exit fullscreen mode

Tooltip Support for .NET MAUI in .NET 7.0

Tooltip Support for .NET MAUI in .NET 7.0

Pointer over visual state

Another essential feature added to the .NET MAUI platform for the .NET 7.0 release is the Pointer over visual state. This is one of the most required visual states in desktop platforms.

Refer to the following code example.

<Label Text="Hover on me to highlight">
 <VisualStateManager.VisualStateGroups>
  <VisualStateGroupList>
   <VisualStateGroup>
    <VisualState x:Name="PointerOver">
     <VisualState.Setters>
      <Setter Property="TextColor" Value="Red"/>
      <Setter Property="Background" Value="Yellow"/>
     </VisualState.Setters>
    </VisualState>
    <VisualState x:Name="Normal">
     <VisualState.Setters>
      <Setter Property="TextColor" Value="Black"/>
      <Setter Property="Background" Value="White"/>
     </VisualState.Setters>
    </VisualState>
   </VisualStateGroup>
  </VisualStateGroupList>
 </VisualStateManager.VisualStateGroups>
</Label>
Enter fullscreen mode Exit fullscreen mode

Pointer Over Visual State for .NET MAUI in .NET 7.0

Pointer Over Visual State for .NET MAUI in .NET 7.0

Right-click gesture

Right-click gesture support is also now available in .NET MAUI. With the TapGestureRecognizer class, a new API called Buttons is added in which the Primary value refers to the left-click, which we already have, and the Secondary value refers to the right-click.

Refer to the following code example.

<Image x:Name="mouseClickImage" Source="mouseclick.png" WidthRequest="250" HeightRequest="250">
 <Image.GestureRecognizers>
  <TapGestureRecognizer Buttons="Primary" Tapped="TapGestureRecognizer_Tapped" />
  <TapGestureRecognizer Buttons="Secondary" Tapped="TapGestureRecognizer_Tapped_1"/>
 </Image.GestureRecognizers>
</Image>
Enter fullscreen mode Exit fullscreen mode

Right-Click Gesture Support for .NET MAUI in .NET 7.0

Right-Click Gesture Support for .NET MAUI in .NET 7.0

Conclusion

Thanks for reading! I hope you enjoyed learning about these new features of .NET MAUI available in the .NET 7.0 release. Please give them a try. Also, we at Syncfusion have released a service pack for our Essential Studio 2022 Volume 3 release. We are excited to announce that with this service pack, our controls for .NET MAUI are now compatible with .NET 7.0.

Our .NET MAUI components are compatible with the following development environments:

  • Microsoft Visual Studio 2022 17.4.0 Preview 6.0 (.NET MAUI version 6.0.541) with .NET 7.0.
  • Microsoft Visual Studio 2022 17.4.0 Preview 6.0 (.NET MAUI version 6.0.541) with .NET 6.0.
  • Microsoft Visual Studio 2022 17.4.0 (.NET MAUI version 6.0.541) with .NET 6.0.
  • Visual Studio 2022 for Mac 17.4 Preview with .NET 6.0.

So now you can create projects targeting .NET 7.0 and reference our service pack NuGet packages either from NuGet Gallery or you can use the installer available from the Syncfusion website. Depending on your license, you can download the licensed installer or use our trial installer.

If you have any questions or comments, you can reach us through our support forum, support portal, or feedback portal. We are always happy to assist you!
ProgressBar")

Top comments (0)