简体   繁体   English

使用 WPF 的 VSIX 的 Visual Studio 自定义窗口在其他项目中找不到主题

[英]Visual Studio Custom Window for VSIX using WPF Can't find theme in other project

I developed a stand alone WPF project with the ShinyBlue.xaml theme which works fine.我开发了一个带有 ShinyBlue.xaml 主题的独立 WPF 项目,效果很好。 Now I want to create a VSIX project to include some user controls from that project right in Visual Studio.现在我想创建一个 VSIX 项目,以在 Visual Studio 中包含该项目中的一些用户控件。

在此处输入图片说明

Problem问题

The VSIX project XAML shows the error above. VSIX 项目 XAML 显示了上述错误。 Where poc:UCMAIN is a user control in the first project that works perfect!其中 poc:UCMAIN 是第一个完美运行的项目中的用户控件!

Possible Solutions可能的解决方案

  1. Get rid of my styling in first project that required a static resource due to the stlye based on property.摆脱我在第一个项目中由于基于属性的风格而需要静态资源的样式。 I don't want that because I won't get the color.我不想要那个,因为我不会得到颜色。 Not a good solution.不是一个好的解决方案。
  2. Copy the theme into the VSIX project and try to get is found there.将主题复制到 VSIX 项目中并尝试在那里找到。 Problem with that is there is not app.config file in VSIX projects.问题在于 VSIX 项目中没有 app.config 文件。 I can add a merged dictionary to the VSIX project main window but.... it still doen't locate the BlueButton Resource.我可以将合并的字典添加到 VSIX 项目主窗口,但是....它仍然找不到 BlueButton 资源。

Question问题

Why does VSIX project show the error above?为什么VSIX项目显示上面的错误? How do I fix it?我该如何解决?

Solution VSIX custom windows doesn't appear to reach into the other included Project's XAML resource directories.解决方案VSIX 自定义窗口似乎无法访问其他包含的项目的 XAML 资源目录。 Even when the merged dictionary points to the theme.即使合并的字典指向主题。

I was using global styling with the targetType parameter and the basedOn parameter specifying a key I placed into the theme to "grab" that color for those buttons.我使用全局样式与 targetType 参数和 basedOn 参数指定我放置在主题中的键以“抓取”这些按钮的颜色。

  1. I removed the key value我删除了键值
  2. I moved command parameter bindings from the resources styling area to be contained in each button.我将命令参数绑定从资源样式区域移到每个按钮中。
  3. Themes may be used but the Main.XAML control must merge the theme dictionary instead of the app.config file which is not present in VSIX Tool Window solutions.可以使用主题,但 Main.XAML 控件必须合并主题字典,而不是 VSIX 工具窗口解决方案中不存在的 app.config 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM