问题描述
为什么 Visual Studio 不允许我在 DLL 项目中创建 WPF 窗口?
我通过在应用程序项目中创建一个窗口并将其复制到我的 DLL 项目来解决"它.我还发现我可以创建一个 UserControl 并将基类更改为Window".
但如果我不得不这样做,那可能是因为我不应该这样做......
解决方案在创建项目时,请确保项目类型为 WPF 用户控件库
.
如果不是,那就不用担心,只需编辑 csproj 文件并确保 <ProjectTypeGuids>
元素在 Project/PropertyGroup
下包含以下 GUID>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
此外,请确保您在项目中引用 PresentationFramework 和 System.Xaml,否则您的代码中将不会获得任何 WPF.
Is there a reason why Visual Studio won't let me create a WPF window in a DLL project?
I "solved" it by creating a window in an Application Project and copying it to my DLL project. I also found that I could just create a UserControl and change the base class to "Window".
But if I had to do it this way, it's maybe because I shouldn't do it...
解决方案Make sure the project type is WPF User Control Library
when you create your project.
If it isn't then no sweat, just edit the csproj file and make sure the <ProjectTypeGuids>
element under Project/PropertyGroup
contain the following GUIDs
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Also, make sure you reference PresentationFramework and System.Xaml in your project, or you will not get any WPF in your code.
这篇关于没有在 DLL 项目中创建 WPF 窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论