Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use WPF with .NET Standard Library

Is it possible to use WPF within an .NET Standard Class Library or is this to be reserved for .NET Core? If so, is it possible to setup a .NET Core Class Library that uses WPF or does it necessarily have to be a .NET Core App?

like image 746
mu88 Avatar asked Oct 29 '25 22:10

mu88


1 Answers

Finally, I got in contact with Microsoft. They were very helpful and provided the following snippet of a *.csproj file to me:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>
</Project>

With this, I get a .NET Core class library including WPF. Additionally, I had to remove App.xaml and App.cs. This was necessary since those contain <Application> tags in XAML which aren’t allowed in WPF libraries.

like image 50
mu88 Avatar answered Nov 01 '25 11:11

mu88



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!