更新时间:2023-12-05 23:37:46
从 Visual Studio 16.5 Preview 1 开始,Visual Studio 内置了对 Windows 窗体设计器的支持.使用设计器:
Starting from Visual Studio 16.5 Preview 1, there is builtin support for Windows Forms designer in Visual Studio. To use the designer:
更多信息:
请记住,在此版本中,设计器尚不支持许多控件.
Keep in mind, in this release, many controls aren’t yet supported in designer.
从 Visual Studio 16.5 Preview 1 开始,Visual Studio 内置了对 Windows 窗体设计器的支持.但是对于旧版本,您可以使用以下解决方法:
Starting from Visual Studio 16.5 Preview 1, there is builtin support for Windows Forms designer in Visual Studio. But for older versions you can use the following workaround:
目前,有一个解决方法 用于将经典 .NET Windows 窗体设计器用于 .NET CORE Windows 窗体项目.
At the moment, there is a workaround for using Classic .NET Windows Forms Designer for .NET CORE Windows Forms projects.
解决方法依赖于在同一解决方案中使用经典 WinForms 应用程序和 CORE WinForms 应用程序,并具有相同的根命名空间.
The workaround relies on having Classic WinForms App and CORE WinForms app in the same solution, having the same root namespace.
要添加新的可设计项,每次要添加新项时,都需要将其添加到经典项目中,然后将生成的3个文件(.cs、.designer.cs、.resx)移动到CORE应用程序中,然后将它们添加为经典应用的链接.
For adding new designable items, every time which you want to add new item, you need to add it to classic project, then move the 3 generated files (.cs, .designer.cs, .resx) to the CORE app, then adding them as link to the classic app.
对于编辑,由于它们在经典应用中作为链接提供,因此请在经典应用的设计器中进行编辑.所有更改都对 CORE 应用可见.
For editing, since they are available as a link in classic app, edit them in the designer of classic app. All changes are visible to CORE app.
准备使用 Windows Forms Designer for .NET Core Winforms App 的解决方案
添加表单或用户控件
每次要添加新的表单或用户控件时,都需要执行以下步骤:
Every time which you want to add a new form or user control, you need to do the following steps:
现在,只要您需要在核心窗体或用户控件文件之一上使用设计器,只需使用经典 Windows 窗体设计器打开经典框架项目中的链接文件即可.
Now, whenever you need to use the Designer on one of the Core Form or UserControl files, simply open the linked files in the Classic Framework project with the Classic Windows Forms Designer.
WPF .NET Core Designer 的 GA 版本已与 .NET Core 3.0 同时发布,并随 Visual Studio 一起发布.
The GA version of the WPF .NET Core Designer has been released at the same time as .NET Core 3.0 and it comes with Visual Studio.
参考:
WPF 设计器完全独立于 Windows 窗体设计器.我们在 .NET Core 3.0 的同时发布了 WPF .NET Core Designer 的 GA 版本,并且它带有 Visual Studio.在 Visual Studio 16.3.0 版中,我们遇到了默认情况下启用 XAML 设计器属性设置为 false 的问题.这意味着当您单击 .xaml 文件时,设计器不会自动打开.升级到已修复此问题的最新 Visual Studio 版本 16.3.1.修复它的另一个选项是转到工具 -> 选项 -> XAML 设计器并选中启用 XAML 设计器.
WPF Designer is completely independent of the Windows Forms Designer. We released its GA version of the WPF .NET Core Designer at the same time as .NET Core 3.0 and it comes with Visual Studio. In Visual Studio version 16.3.0 we had an issue with the Enable XAML Designer property set to false by default. That means that when you click on .xaml files, the designer doesn’t open automatically. Upgrade to the latest Visual Studio version 16.3.1 where this issue is fixed. Another option to fix it is to go to Tools -> Options -> XAML Designer and check Enable XAML Designer.