App.xaml中合并的词典

Nic*_*rin 2 wpf xaml app.xaml mergeddictionaries

我有一堆Xaml矢量图标分开.xaml.我window使用这个指令将它们加载到我的内部:

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/ScreenToGif;component/Themes/IconSet.xaml"></ResourceDictionary>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

我有很多窗口,所以我想简单地把这个代码放在里面App.xaml.

我正在尝试这个:

<Application.Resources> <!-- Error, The property "Resources" can only be set once. -->
    <ResourceDictionary x:Key="IconSet"> <!--Not sure why this?-->
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Mine;component/Themes/Theme.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

<!--Here goes the rest of the file, with Style and DropShadowEffect... -->
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

所以这是问题所在:

所有示例都不使用x:Key属性,但它给我一个错误,说我需要.当我这样做时,它说我不能拥有多个属性Resource......

Hee*_*til 17

请参阅评论文字

<Application.Resources>    
    <ResourceDictionary>           
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Mine;component/Themes/Theme.xaml"/>
        </ResourceDictionary.MergedDictionaries>

        <!--You have to add other style here only-->

    </ResourceDictionary>

<!--Not Here-->

</Application.Resources>
Run Code Online (Sandbox Code Playgroud)