3

I have created a brand-new WinUI 3 / Windows App SDK project in VS2022 Pro using a Blank Project template. When I open MainWindow.xaml in design mode after successfully building the project I get the following error message:

enter image description here

There doesn't seem to be anything missing under Packages, nor are there any errors anywhere else. As far as I can tell, all the necessary SDKs have been installed:

enter image description here

I am running VS2022 as Administrator in Windows 11 Enterprise v10.0.22621.

Any idea what I am missing?


UPDATE 1

Updated the NuGet packages, rebuilt the project and am now seeing three errors: enter image description here


UPDATE 2

Accepted auto-suggested fixes to add xaml: and controls: namespaces in front of XAML tag names and now the errors are gone: enter image description here

However, so is the ability to open the page in VS designer even though it's enabled in Tools > XAML Designer.

Moreover, when I open the project in VS Blend it doesn't show the designer either.

What is missing from my project?

3
  • First thing is to upgrade the Windows App SDK packages to latest 1.3xx version (using Nuget update) Commented May 4, 2023 at 17:12
  • Done that and now I am seeing actual errors (see the update). Commented May 4, 2023 at 18:33
  • Strange. You can try to close VS and remove all bin and obj directories, or clear all nuget cache stackoverflow.com/questions/30933277/…, etc. Commented May 4, 2023 at 21:46

1 Answer 1

3

WinUI 3 doesn't have a XAML designer and doesn't work with Blend. There's an ongoing discussion in the repo here. We'll might get one in the future but not anytime soon. It's mentioned in this WinUI Community Call Feb 2023.

Also, the XAML designer shouldn't be up in your project. A few months ago I had the same experience but I'm not sure why. I guess restarting Visual Studio or reloading the project fixed the issue that time and the XAML designer has not been up anymore.

BTW, this is how a default WinUI 3 MainWindow.xaml should look like:

<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Window
    x:Class="TestWinUI3.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:TestWinUI3"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
    </StackPanel>
</Window>

If you keep having basic initial problems, make sure you have installed all the workloads and components, and create the project using [Blank App, Packaged (WinUI 3 in Desktop)] template.

Sign up to request clarification or add additional context in comments.

1 Comment

WinUI 3 / .NET MAUI XAML designer is not supported in Visual Studio 2022. learn.microsoft.com/en-us/visualstudio/xaml-tools/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.