通过 Visual Studio 2010 将 WPF 资源字典插入到类库中 [英] Insert a WPF Resource Dictionary into a class library via Visual Studio 2010

查看:42
本文介绍了通过 Visual Studio 2010 将 WPF 资源字典插入到类库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类库,想更改类型,以便我也可以添加 WPF 资源字典.我添加了 WPF 引用,并尝试将 AssemblyInfo.cs 文件与允许添加此类资源文件的项目同步,但没有成功.

I have a class library and want to change the type so that I also can add a WPF resource dictionaries. I have added the WPF references and also tried to sync the AssemblyInfo.cs file with a project that allows the addition of such resource files, however without success.

如果我使用 Visual Studio 中的 add-new-dialog,WPF 资源字典的模板不可用 - 如果我手动创建文件然后引用它,一切正常.

If I use the add-new-dialog from Visual Studio, the template for WPF resource dictionaries is not available - If I create the file manually and then reference it, all works fine.

如何将我的项目更改为 WPF 自定义控件库项目,以便 Visual Studio 允许我添加 WPF 资源词典.或者是否有任何缺点或陷阱,因此我不能这样做并更好地创建新的项目文件?

How can I change my project to a WPF custom control library project so that Visual Studio allows me to add WPF resource dictionaries. Or are there any drawbacks or pitfalls so that I must not do that and better create a new project-file?

推荐答案

好像是在 csproj-File 中定义的.如果我将以下行添加到 PropertyGroup-Section 中,我可以做我想要的:

It seems to be defined in the csproj-File. If I add the following line into the PropertyGroup-Section, I can do what I'm looking for:

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

请注意
虽然我已经找到了定义所在的位置,但是我并没有使用更改后的 csproj-File 版本.我创建了一个具有所需设置的新项目.控件库和类库之间似乎有很多额外的项目设置,也许只添加上述 guid 可能会导致项目/解决方案的意外行为.

Please note
Although I have found the location where the definiton resides, I have not used the changed version of the csproj-File. I have created a new project with the desired settings. There seem to be a lot of additional project-settings between a control library and a class library and maybe only adding the above guids may result in unexpected behaviour of the project/solution.

这篇关于通过 Visual Studio 2010 将 WPF 资源字典插入到类库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆