我在一个单独的 .xaml
中有一堆 Xaml 矢量图标.我将它们装入我的 window
使用这个指令:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ScreenToGif;component/Themes/IconSet.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
我有很多窗口,所以我想简单地将此代码放在
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>
所以这里的问题是:
所有示例都不使用
x:Key
属性,但它给了我一个错误,说我需要。当我这样做时,它说我不能拥有多个属性
Resource
...
最佳答案
请看注释文字
<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>
关于wpf - App.xaml 中的合并字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27215155/