C# 来自绑定的wpf ResourceDictionary源

C# 来自绑定的wpf ResourceDictionary源,c#,wpf,C#,Wpf,在我的app.xaml中,我有很多样式要加载,这就是那个列表 <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Themes/dark.xaml"/> <ResourceDictionary

在我的app.xaml中,我有很多样式要加载,这就是那个列表

    <Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Themes/dark.xaml"/>
            <ResourceDictionary Source="Themes/Orange.xaml"/>
            <ResourceDictionary Source="Controls/Button.xaml"/>
            <ResourceDictionary Source="Controls/CheckBox.xaml"/>
            <ResourceDictionary Source="Controls/Controls.xaml"/>
            <ResourceDictionary Source="Controls/ContextMenu.xaml"/>
            <ResourceDictionary Source="Controls/ScrollBar.xaml"/>
            <ResourceDictionary Source="Controls/ScrollViewer.xaml"/>
......
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

......
现在我需要在运行时将两个firs源url更改为Properties.Settings.Default的值 我不知道我能做什么 我搜索了一下,但没有什么东西找不懂

var newsource1= new Uri("pack://siteoforigin:,,,/resources/xxxx.xaml", UriKind.RelativeOrAbsolute);
var newsource2= new Uri("pack://siteoforigin:,,,/resources/yyyyy.xaml", UriKind.RelativeOrAbsolute);

Application.Current.Resources.MergedDictionaries.Remove(Appl‌​ication.Current.Reso‌​urces.MergedDictiona‌​ries[0]);
Application.Current.Resources.MergedDictionaries.Remove(Appl‌​ication.Current.Reso‌​urces.MergedDictiona‌​ries[1]);

Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = newsource1});
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = newsource2});
因为没有可用于编辑资源字典运行时的功能。可能的解决方案是在运行时删除和添加资源字典

真诚地

蒂亚古·拉詹德兰


**如果有帮助,请将回答标记为答案。

谢谢,我得到了答案