Reputation: 1530
In Visual Studio 2019, if I create a new "WPF Application" using .Net Core (top in the screenshot below) it will create a project for me that does in fact include a working XAML setup. However, there is no way that I can find to add a new XAML window through the VS interface. Right-clicking on a folder, choosing Add and then Window (WPF) just gives you the codebehind, no XAML anywhere.
If instead I create a new "WPF App (.NET Framework)" (bottom in the screenshot) It creates a similar project but I can in fact add XAML windows via right-click and selecting Add as above, including the relevant codebehind.
What gives? If we want to use .Net Core do we have to create the XAML files manually? Am I missing something? XAML is explicitly not listed under the .Net Core option, but the project creation process does indeed create XAML files in the project as expected.
Upvotes: 0
Views: 1907
Reputation: 11
With suggestions above, I was able to get this working in VS2019. To condense the answer:
<UseWPF>true</UseWPF>
to the first <PropertyGroup>
.Upvotes: 1
Reputation: 1530
I seem to have answered my own question but it seems useful so I will leave it up here. When you create your .Net Core WPF Application, if you choose .NetCore 3.1 (Long-term support) you get the behavior I describe above (no ability to add XAML windows). If you choose .NET 5.0 (Current) it works as expected and you can add XAML windows.
Upvotes: 0