As shown here and here (both on the same Microsoft page) a .NET 6.0 application can target Winforms and WPF. But will that cause conflicts at some point? What isn't clear is whether both can be targeted in the same project.
So, is it OK to target both together or will alters the MSBuild pipeline to correctly process a Windows Forms project
conflict with alters the MSBuild pipeline to correctly process a WPF project
?
Here's how it looks in Visual Studio in the project's properties tab:
The reason I'm asking is because I want to use certain classes from Winforms in a WPF application.
Yes, it's OK and there are valid scenarios which you may want to add both frameworks. It's already mentioned in the documentations, you can add both, if necessary:
- Add a UI framework property (or both, if necessary):
- Set UseWPF to true to import and use WPF.
- Set UseWindowsForms to true to import and use WinForms.
And also the example shows the same:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<!-- and/or -->
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With