[英]Convert csproj file from winform to wpf
I have a Winform app that has one very simple form, a program.cs main file and about 60 back-end .cs files. 我有一个Winform应用程序,它有一个非常简单的表单,program.cs主文件和大约60个后端.cs文件。 I want to convert the project to a WPF application.
我想将项目转换为WPF应用程序。 Looking here didn't show anything close to what I want to do.
看这里没有显示任何接近我想做的事情。
I need to 我需要
Then, I will manually split the content of the old forms file between the view and the viewmodel files. 然后,我将在视图和viewmodel文件之间手动拆分旧表单文件的内容。
Any way of doing that easier than starting from scratch? 有什么方法比从头开始更容易?
EDIT: I would rather not host the new WPF ui into the old winforms shell but replace the current forms application by a wpf one. 编辑:我宁愿不将新的WPF ui托管到旧的winforms shell中,而是用wpf替换当前的表单应用程序。
EDIT2: I do not want to convert the entire project and the architecture to WPF (as it was asked and answered several times on SO), I totally understand that these are 2 different framework and I am totally willing to do the change manually. EDIT2:我不想对整个项目和架构转换WPF(因为它是提出和回答的SO几次),我完全理解,这些是2个不同的框架和我完全愿意做手工的变化。 I want to convert the csproj so it will compile as a WPF app instead of a Forms app.
我想转换csproj所以它将编译为WPF应用程序而不是Forms应用程序。
The short answer for those that don't want to do the comparison themselves is that a WPF .csproj file contains an addition property: 对于那些不想进行比较的人来说,简短的答案是WPF .csproj文件包含一个附加属性:
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Just put that in the first <PropertyGroup>...</PropertyGroup>
section, it shouldn't matter where. 只需将它放在第一个
<PropertyGroup>...</PropertyGroup>
部分中,它应该无关紧要。
The meaning of {60dc8134-eba5-43b8-bcc9-bb4bc16c2548}
is that this is a WPF project, and {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
indicates a C# project. {60dc8134-eba5-43b8-bcc9-bb4bc16c2548}
是这是一个WPF项目, {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
表示一个C#项目。 You can learn more about project type guids from this SO question . 您可以从此SO问题中了解有关项目类型指南的更多信息。
It seems from your edit2 that you just want to change the project type from "Winforms" to "WPF" without changing any of the project items. 从您的edit2看来,您只想将项目类型从“Winforms”更改为“WPF”而不更改任何项目项。 I don't know why you want to do this, but try creating an empty Winforms project, then creating an empty WPF project, then comparing the two project files.
我不知道你为什么要这样做,但尝试创建一个空的Winforms项目,然后创建一个空的WPF项目,然后比较两个项目文件。
Whatever the difference is between the two empty projects, make that change to your existing Winforms project. 无论两个空项目之间有什么区别,都要对现有的Winforms项目进行更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.