.net 找不到资源字典

.net 找不到资源字典,.net,wpf,xaml,resourcedictionary,.net,Wpf,Xaml,Resourcedictionary,下面的图片说明了一切。WPF找不到某些xaml文件。我试着把它们搬来搬去,但没有用。它们都将其生成操作设置为Page,并将自定义工具设置为MSBuild:Compile。不知道我错过了什么 编辑 根据要求,这里有两个示例xaml文件。其中一个有效,另一个无效 GroupBox.xaml(工作模式) Toolbox.xaml(不工作) 编辑2 这可能看起来很疯狂,但将x:Class=“DiagramDesigner.App”更改为x:Class=“App”为我修复了所有错误。看起来VB.

下面的图片说明了一切。WPF找不到某些xaml文件。我试着把它们搬来搬去,但没有用。它们都将其生成操作设置为Page,并将自定义工具设置为MSBuild:Compile。不知道我错过了什么

编辑 根据要求,这里有两个示例xaml文件。其中一个有效,另一个无效

GroupBox.xaml(工作模式)


Toolbox.xaml(不工作)


编辑2
这可能看起来很疯狂,但将
x:Class=“DiagramDesigner.App”
更改为
x:Class=“App”
为我修复了所有错误。看起来VB.NET不希望我在该属性中指定名称空间。

尝试将资源添加为

<ResourceDictionary Source="pack://application:,,,/DiagramDesigner;component/Resources/Themes/CommonThemes.xaml" />

Application.Current.Resources.MergedDictionaries.Add(新资源字典(){Source=resource})

这是在黑暗中拍摄的,但是将
x:Class=“DiagramDesigner.App
更改为
x:Class=“App”


-)

假设你已经完成了一次清理和重建工作?这对我来说总是解决不了的WPF@Nico:这对我不起作用。我也重新启动了VS。需要注意的是,问题仅限于某些文件,而不是所有文件。您使用的是网络共享还是外部存储?工作文件和非工作文件中一个文件的内容是什么一个?请在一个示例项目中逐个尝试资源字典。检查它是否工作。结果完全相同。适用于快照中它工作的资源字典,对其他资源字典显示错误。如果此样式在xaml中不工作,那么它如何在代码隐藏中工作。您刚刚确认了吗?那么这是一个答案还是一个注释?顺便说一句,我想在你上次发表评论时,你的大写锁定键可能已被切换。这正是解决方案。你是如何猜得如此准确的?:-)@dotNET当然可以自由回答你自己的问题,我将删除这篇滑稽的帖子。或者,如果你愿意,可以将我的作为答案。:-)
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:s="clr-namespace:DiagramDesigner">
<Style TargetType="{x:Type s:Toolbox}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
  <Setter.Value>
    <ControlTemplate TargetType="{x:Type s:Toolbox}">
      <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
              Padding="{TemplateBinding Control.Padding}"
              BorderBrush="{TemplateBinding Border.BorderBrush}"
              Background="{TemplateBinding Panel.Background}"
              SnapsToDevicePixels="True">
        <ScrollViewer VerticalScrollBarVisibility="Auto">
          <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
        </ScrollViewer>
      </Border>
    </ControlTemplate>
  </Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
  <Setter.Value>
    <ItemsPanelTemplate>
      <WrapPanel Margin="0,5,0,5"
                 ItemHeight="{Binding Path=ItemSize.Height, RelativeSource={RelativeSource AncestorType=s:Toolbox}}"
                 ItemWidth="{Binding Path=ItemSize.Width, RelativeSource={RelativeSource AncestorType=s:Toolbox}}"/>
    </ItemsPanelTemplate>
  </Setter.Value>
  </Setter>
  </Style>
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/DiagramDesigner;component/Resources/Themes/CommonThemes.xaml" />
 Application.Current.Resources.MergedDictionaries.Clear();

var resource = new Uri("pack://application:,,,/DiagramDesigner;component/CultureDictionary.xaml");