我假定你在<代码>应用<>代码/代码>上重新进行合并,否则,你只能实行中间控制,其唯一工作是主办主题词典。 因此,我建议采用多层次的方法,使第一个合并的字典能够容纳所有与主题有关的字典:
<Application.Resources>
<!-- all application level resources -->
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- theme-related resources -->
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- merge in theme-related dictionaries here -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<!-- merge in other application-level dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- other resources -->
<SolidColorBrush x:Key="Foo">Black</SolidColorBrush>
</ResourceDictionary>
</Application.Resources>
现在,你只能把主题相关资源作为目标,其代码如下:
Application.Current.Resources.MergedDictionaries[0].Clear();
Application.Current.Resources.MergedDictionaries[0].Add(...);