c# - 如何在 .NET Core 3.0 中为 WPF 应用程序引用 System.Windows.Forms?

标签 c# wpf .net-core folderbrowserdialog

我正在将我的 WPF 桌面应用程序从 .NET Framework 迁移到 Core 3.0。
我正在使用 System.Windows.Forms.FolderBrowserDialog() ,现在我一直在纠结如何将此引用添加到 Core 项目。没有可用的“System.Windows.Forms”NuGet 包,是吗?有没有其他方法可以在 Core 中显示 FolderBrowserDialog?
更新
我使用默认模板创建了 Core 项目,然后将 .cs 和 .xaml 文件复制并粘贴到其中。 .csproj 文件如下所示:

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

最佳答案

您需要向 csproj 添加一个额外的开关:

<UseWindowsForms>true</UseWindowsForms>
在下面添加使用Wpf .然后尝试重建。在此之后,您应该能够使用 Forms 命名空间。

关于c# - 如何在 .NET Core 3.0 中为 WPF 应用程序引用 System.Windows.Forms?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58844785/

相关文章:

c# - 你能提供数组排序的替代算法吗?

.net-core - 使用 Azure AD v2.0 通过适用于 .NET 的 Azure 管理库进行身份验证

c# - 网络核心 : Find Data Type for any Variable Field in Class

c# - EF模型生成问题

c# - 在 Properties.Settings.Default 与注册表中存储设置

c# - 我应该显式设置属性吗?

c# - 为什么适配器不工作?

c# - DatePicker 其他格式的默认日期

列名中的 C# DataTable DataGrid 特殊字符 "/"(斜杠)

c# - EF Core 到 Mysql 表绑定(bind)