Dynamically changing themes from DLL at run-time
-
How do we change themes dynamically, if themes are stored into a DLL? Generally, if theme is in form of .xaml file, we write in xaml
And in CS:
ResourceDictionary skin = new ResourceDictionary();
skin.Source = new Uri(@"Themes/ShinyRed.xaml", UriKind.Relative);
Window win = Window.GetWindow(this);
win.Resources.MergedDictionaries.Clear();
win.Resources.MergedDictionaries.Add(skin);where 'Themes' is folder name and 'ShinyRed.xaml' is theme name. Now, if theme is in form of DLL file, we write in xaml
where 'ThemeDll' is the name of DLL, and ShinyBlue.xaml is theme name. How to get same result at run-time?
-
How do we change themes dynamically, if themes are stored into a DLL? Generally, if theme is in form of .xaml file, we write in xaml
And in CS:
ResourceDictionary skin = new ResourceDictionary();
skin.Source = new Uri(@"Themes/ShinyRed.xaml", UriKind.Relative);
Window win = Window.GetWindow(this);
win.Resources.MergedDictionaries.Clear();
win.Resources.MergedDictionaries.Add(skin);where 'Themes' is folder name and 'ShinyRed.xaml' is theme name. Now, if theme is in form of DLL file, we write in xaml
where 'ThemeDll' is the name of DLL, and ShinyBlue.xaml is theme name. How to get same result at run-time?
I think you can get the result same way as you do it with normal xaml file
in CS:
ResourceDictionary skin = new ResourceDictionary();
Instead of
skin.Source = new Uri(@"Themes/ShinyRed.xaml", UriKind.Relative);
Use this
skin.Source = new Uri(@"/ThemeDll;component/ShinyBlue.xaml", UriKind.Relative);
Window win = Window.GetWindow(this);
win.Resources.MergedDictionaries.Clear();
win.Resources.MergedDictionaries.Add(skin);it works fine for me. I hope i got your question correctly.
Work relieves us from three great evils, boredom, vice, and want.
-
I think you can get the result same way as you do it with normal xaml file
in CS:
ResourceDictionary skin = new ResourceDictionary();
Instead of
skin.Source = new Uri(@"Themes/ShinyRed.xaml", UriKind.Relative);
Use this
skin.Source = new Uri(@"/ThemeDll;component/ShinyBlue.xaml", UriKind.Relative);
Window win = Window.GetWindow(this);
win.Resources.MergedDictionaries.Clear();
win.Resources.MergedDictionaries.Add(skin);it works fine for me. I hope i got your question correctly.
Work relieves us from three great evils, boredom, vice, and want.
Thanks! :)