我在分隔的.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
...
答案 0 :(得分: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>