次のように、App.Xamlでテーマをマージできます。
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="defaulttheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
defaulttheme.xamlファイルはプロジェクトのルートにある必要があります。テーマ用に独自のプロジェクトを構築したい場合は、次のようにリソースをマージできます。
<ResourceDictionary Source="/MyThemeProject;component/defaulttheme.xaml" />
ここで、defaulthteme.xamlもルートのMyThemeProjectに含まれている必要があり、メインプロジェクトからそのプロジェクトへの追加参照を追加することを忘れないでください。
構造を構築するために、好きなようにフォルダを追加できます。
<ResourceDictionary Source="/MyThemeProject;component/Folder1/Folder2/defaulttheme.xaml" />
テーマを切り替えるには、最初にMergedDictionariesをクリアしてから、新しいテーマを追加します
NewTheme = new Uri(@"/MyThemeProject;component/folder1/Folder2/bluetheme.xaml", UriKind.Relative);
Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(NewTheme);
よろしく
フルッサー