如何在WPF应用程序的.NET Core 3.0中引用System.Windows.Forms? [英] How to reference System.Windows.Forms in .NET Core 3.0 for WPF apps?

查看:47
本文介绍了如何在WPF应用程序的.NET Core 3.0中引用System.Windows.Forms?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将WPF桌面应用程序从.NET Framework迁移到Core 3.0.我使用的是System.Windows.Forms.FolderBrowserDialog(),现在我陷入了如何将此引用添加到Core项目中的问题.没有"System.Windows.Forms".NuGet软件包可用吗?有没有其他方法可以在Core中显示FolderBrowserDialog?

I'm migrating my WPF desktop app from .NET Framework to Core 3.0. I was using System.Windows.Forms.FolderBrowserDialog() and I'm now stuck on how to add this reference to the Core project. There is no "System.Windows.Forms" NuGet package available, is there? Is there any alternative way to display the FolderBrowserDialog in Core?

更新

我使用默认模板创建了Core项目,然后将.cs和.xaml文件复制并粘贴到其中..csproj文件如下所示:

I created the Core project using the default template and then copied and pasted .cs and .xaml files into it. The .csproj file looks like this:

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

推荐答案

您需要在csproj中添加其他开关:

You need to add to csproj an additional switch:

<UseWindowsForms>true</UseWindowsForms>

将其添加到 UseWpf 下面.然后尝试重建.之后,您应该可以使用Forms命名空间.

Add it below UseWpf. Then try rebuild. After this, you should be able to use Forms namespace.

这篇关于如何在WPF应用程序的.NET Core 3.0中引用System.Windows.Forms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆