Reputation: 1500
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:
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:
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:
UPDATE 2
Accepted auto-suggested fixes to add xaml:
and controls:
namespaces in front of XAML tag names and now the errors are gone:
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?
Upvotes: 3
Views: 951
Reputation: 13666
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.
Upvotes: 3