在App.XAML中使用ResourceDictionary时发生WPF/XAML错误

在App.XAML中使用ResourceDictionary时发生WPF/XAML错误,wpf,xaml,resourcedictionary,Wpf,Xaml,Resourcedictionary,我在引用xaml资源字典文件时遇到问题,导致在引用中的ResourceDictionary时出现运行时错误,称“resource x找不到”。但改用Window.Resources节点是可行的 工作代码: <Window.Resources> <ResourceDictionary Source="Resources\Template_1.xaml"> </ResourceDictionary> </Window.Resources>

我在引用xaml资源字典文件时遇到问题,导致在引用中的ResourceDictionary时出现运行时错误,称“resource x找不到”。但改用Window.Resources节点是可行的

工作代码:

<Window.Resources>
    <ResourceDictionary Source="Resources\Template_1.xaml">
    </ResourceDictionary>
</Window.Resources>

我的故障代码:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Resources\Template_1.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

我的问题是我需要在应用范围内的词典。 我正在以StaticResource的身份访问它,模板_1的构建操作设置为“页面”

有什么建议吗

编辑: 这是模板_1.xaml的结构

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:self="clr-namespace:Application_1"
                >
<ControlTemplate x:Key="dict_TabContent" x:Shared="true" >
    <DockPanel>
        ...
    </DockPanel>
</ControlTemplate>
</ResourceDictionary>

...

我怀疑使用
会有所不同,但是你能展示一下吗?你可以发布无法从模板中解析的资源的xaml吗?xaml将结构添加到问题中。感谢您的关注您是否尝试过在应用程序资源场景中设置x:Shared=“false”auf dict\u TabContent?是的,我尝试过:(我正在从头开始重建我的项目,到目前为止它正在工作(还有一些工作要做)