我们的应用程序使用ResourceDictionary
作为其样式。此资源字典本身包含资源字典:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="BridgeIt5/General.xaml" />
<ResourceDictionary Source="BridgeIt5/Brushes.xaml" />
<ResourceDictionary Source="BridgeIt5/Constants.xaml" />
<ResourceDictionary Source="BridgeIt5/Button.xaml" />
...
</ResourceDictionary.MergedDictionaries>
所以,现在,根据构建配置,我们只想更改Brushes.xaml合并资源字典。怎么办呢?
答案 0 :(得分:0)
如果您可以在运行时设置配置,则可以在启动期间执行此操作:
var resourceDictionary = new ResourceDictionary
{
// Pick uri from configuration
Source = new Uri("BridgeIt5/Brushes.xaml"),
};
Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);