找不到资源词典?

Resource dictionary cannot be found?

至少我认为这是问题...

我有一个这样结构的项目(为简洁起见省略了文件)

Project
  Assets
    ResourceDictionaries
       Styles.xaml
  MainWindow.xaml

我在MainWindow.xaml

中引用资源字典如下
<Window.Resources>
  <ResourceDictionary>
     <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Assets/ResourceDictionaries/Styles.xaml"/>
     </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
<Window.Resources/>

但是 none 的样式正在应用于任何元素。

我已检查生成操作是否设置为页面。我也试过给字典中的一些样式一个键,但是 Blend 不能 'see' 这些键。

我做错了什么?

编辑:相关代码。显然,如果我将属性放在它们起作用的实际元素上,但在字典中它们不会:

MainWindowStyles.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Company.Client.Assets.ResourceDictionaries"
                    xmlns:wpf="http://schemas.syncfusion.com/wpf">

    <Style TargetType="{x:Type wpf:RibbonWindow}">
        <Setter Property="wpf:SkinStorage.VisualStyle" Value="Office2010Silver"/>
    </Style>

    <Style TargetType="{x:Type wpf:Ribbon}">
        <Setter Property="BackStageColor" Value="#622166"/>
    </Style>

</ResourceDictionary>

MainWindow.xaml

<wpf:RibbonWindow x:Class="Company.Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:wpf="http://schemas.syncfusion.com/wpf"
        xmlns:local="clr-namespace:Company.Client"
        mc:Ignorable="d"
        Title="MainWindow" Height="600" Width="800">
    <wpf:RibbonWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Assets/ResourceDictionaries/MainWindowStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </wpf:RibbonWindow.Resources>
    <Grid>
        <wpf:Ribbon BackStageHeader="DB">
            <wpf:Ribbon.BackStage>
                <wpf:Backstage>
                    <wpf:BackStageCommandButton Header="Save"/>
                </wpf:Backstage>
            </wpf:Ribbon.BackStage>
        </wpf:Ribbon>
    </Grid>
</wpf:RibbonWindow>

编辑 2: 这是目前已经尝试过的:

使用pack URI语法:

<ResourceDictionary Source="pack://application:,,,/Assets/ResourceDictionaries/Styles.xaml"/>

你试过这两个步骤了吗:

  • 将 MainWindowStyles.xaml 添加到 app.xaml
  • 中的 Application.Resources 部分
  • 为 RibbonWindow 使用显式样式,如下所示:

    <RibbonWindow>
    ...
    <RibbonWindow.Style>
        <StaticResource ResourceKey="RadRibbonWindowStyle"/>
    <RibbonWindow.Style>
    

添加此内容以补充

我的代码现在看起来像这样。我没能让它与 VisualStyle 属性 一起工作,但这样做就可以了。如果有人确实知道如何将其放入资源词典中,将不胜感激。 :)

长话短说,这是基于我和@AlexSeleznyov 之间交流的有效代码

MainWindowStyles.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:wpf="http://schemas.syncfusion.com/wpf">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Syncfusion.Tools.Wpf;component/framework/ribbon/themes/office2010silverstyle.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    <Style x:Key="MainRibbon" TargetType="{x:Type wpf:Ribbon}" BasedOn="{StaticResource Office2010SilverRibbonStyle}">
        <Setter Property="BackStageColor" Value="#622166"/>
    </Style>
</ResourceDictionary>

MainWindow.xaml

<wpf:RibbonWindow x:Class="Company.Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:wpf="http://schemas.syncfusion.com/wpf"
        xmlns:local="clr-namespace:Company.Client"
        mc:Ignorable="d"
        wpf:SkinStorage.VisualStyle="Office2010Silver"
        Title="MainWindow" Height="600" Width="800"
        Icon="Assets/Icons/ApplicationIcon.ico">
    <wpf:RibbonWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Assets/ResourceDictionaries/MainWindowStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </wpf:RibbonWindow.Resources>
    <Grid>

        <wpf:Ribbon BackStageHeader="File" Style="{StaticResource MainRibbon}">
            <wpf:Ribbon.BackStage>
                <wpf:Backstage>
                    <wpf:BackStageCommandButton Header="Save"/>
                </wpf:Backstage>
            </wpf:Ribbon.BackStage>
        </wpf:Ribbon>
    </Grid>
</wpf:RibbonWindow>