VSIX 中的主要资源字典

问题描述

我正在使用 WPF 编写一些 VSIX。我希望所有 TextBlock 控件都具有指定的颜色。所以我添加一个带有资源字典的 xaml 文件

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0"
>


    <Style targettype="{x:Type TextBlock}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static ui:EnvironmentColors.ToolWindowTextBrushKey}}"/>
    </Style>
</ResourceDictionary>

接下来,我选择了 Page 作为此 xaml 的构建操作,并在我的 Toolwindow 对话框中使用它:

ResourceDictionary resources = new ResourceDictionary();
resources.source = new Uri("pack://application:,/Nerdolando.NerdX;component\\UI\\Styles.xaml");
Resources.MergedDictionaries.Add(resources);

但它不起作用。当我在 ToolWindow 的 xaml 中键入此样式时,它就可以工作了。有什么区别?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)