Insert a WPF Resource Dictionary into a class libr

2019-04-28 04:25发布

问题:

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.

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.

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?

回答1:

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>

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.