Categories
.NET .NET 8 .NET 9 .NET Conf .NET MAUI Android Blazor C# Desktop Developer General Getting Started Hybrid iOS macOS Mobile Preview Tools Video Visual Studio VS Code Web What's New Windows Xamarin Xamarin.Forms

.NET MAUI – Enable Debugger-Detached XAML Live Preview in Visual Studio 2022

Not confined to .NET MAUI, the XAML Live Preview functions as an invaluable tool for inspecting the UI and its associated properties in XAML apps overall.

However, it is imperative that the app be connected to the debugger, is it not? Yes, that is prior to the intro of the debugger-detached XAML Live Preview in VS2022, v17.13 Preview 1.0.

Yesterday, during the .NET MAUI session at .NET Conf 2024 (YouTube clip linked), David and Rachel provided an insightful overview of its functionality.

To know about this virtual event, consult this .NET Conf 2024 article and this detailed article outlining the comprehensive features of .NET MAUI 9.

In this article, we will examine in detail how to enable this XAML Live Preview feature and utilize it effectively.

Settings:

Since this feature is presently marked as a preview, it is imperative that it be activated within the Settings prior to usage. Steps detailed below:

Note: The preview and stable versions of Visual Studio can be installed concurrently on the same machine.

  • Launch VS2022 v17.13 Preview 1.0
  • Open the Options dialog:
    • Navigate to the Tools menu and select the Options menu item
    • Alternatively, use the hotkey: Alt+T+O
  • In the Options dialog, enter the keyword xaml into the Search Option text field at the top left of the dialog:
    • Use the hotkey: Ctrl+E to focus on the search field
  • Select the Preview Features node under the Environment category
  • On the right pane, verify the Enable XAML Live Preview Launch checkbox option
.NET MAUI - VS2022 17.13 Preview 1.0 - Enable Debugger-detached XAML Live Preview
.NET MAUI – VS2022 17.13 Preview 1.0 – Enable Debugger-detached XAML Live Preview

Use Live Preview:

Now it’s time for action. To open the Live Preview tool window, right-click on any XAML node in any view/page and select View Live Preview from the flyout menu. Refer to the screenshot below.

View Live Preview option in the Flyout menu
View Live Preview option in the Flyout menu

For the Live Preview to function correctly, the app must be running. If it is not, the tool window will display a button titled Launch Previewer as shown in the below screenshot. Click this button to start the app.

Launch XAML Live Preview in VS2022 17.13 Preview 1.0
Launch XAML Live Preview in VS2022 17.13 Preview 1.0

Alternatively, you can launch the app without attaching the debugger by using the hotkey Ctrl+F5 or by clicking the outlined Play button in the Debug toolbar. And then select the Show in XAML Live Preview button (video camera icon) in the application toolbar (represented by two stacked lines, click to expand).

VS2022 - Application toolbar - Show in XAML Live Preview option
VS2022 – Application toolbar – Show in XAML Live Preview option

Output:

VS2022 - .NET MAUI - XAML Live Preview
VS2022 – .NET MAUI – XAML Live Preview

Further Reading:

Happy coding. Stay connected as we continue to learn and share the experiences from this exciting journey of being a .NET developer.

By Vijay Anand E G

A software professional with over a decade long industry experience in developing products that spans across desktop, mobile, and web.

One reply on “.NET MAUI – Enable Debugger-Detached XAML Live Preview in Visual Studio 2022”

Comments are closed.

Discover more from Developer Thoughts

Subscribe now to keep reading and get access to the full archive.

Continue reading