更新时间:2023-01-31 09:50:01
从Visual Studio 16.5 Preview 1开始,Visual Studio中内置了对Windows Forms Designer的支持。若要使用设计器:
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开始,对Windows Forms Designer的内置支持在Visual Studio中。但是对于较旧的版本,您可以使用以下解决方法:
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 Forms Designer用于.NET CORE Windows Forms项目。
At the moment, there is a workaround for using Classic .NET Windows Forms Designer for .NET CORE Windows Forms projects.
解决方法取决于在同一解决方案中具有Classic 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用于.NET Core Winforms App
添加表单或UserControl
每次要添加新表单或用户控件时,都需要执行以下步骤:
Every time which you want to add a new form or user control, you need to do the following steps:
现在,每当需要在Core Form或UserControl文件之一上使用Designer时,只需使用Classic Windows Forms Designer在Classic Framework项目中打开链接的文件即可。
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的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.