Hello,
After sticking a while how to use themes dynamicly we found a simple solution, don't imaging why the ThemeResolutionService not instances the required theme.
ThemeResolutionService provides several methods to register a theme so we ware expecting he loads also the theme and instances it if required by setting ApplicationThemeName. It doesn't do so.
Our solution is quiet simple. Take a Dictionary<string, RadThemeComponentBase> in class being alive the whole time your application runes (static class or like us in the AddIn class). If a theme is required so check your dictionary if theme is loaded otherwise create object (f.i. with Activator.CreateInstance<...>()) and add it to the dictionary. Now the theme is alive and each change on ThemeResolutionService.ApplicationThemeName uses the living theme.
Hope it helps others
Regards from Leipzig
Holger Boskugel
After sticking a while how to use themes dynamicly we found a simple solution, don't imaging why the ThemeResolutionService not instances the required theme.
ThemeResolutionService provides several methods to register a theme so we ware expecting he loads also the theme and instances it if required by setting ApplicationThemeName. It doesn't do so.
Our solution is quiet simple. Take a Dictionary<string, RadThemeComponentBase> in class being alive the whole time your application runes (static class or like us in the AddIn class). If a theme is required so check your dictionary if theme is loaded otherwise create object (f.i. with Activator.CreateInstance<...>()) and add it to the dictionary. Now the theme is alive and each change on ThemeResolutionService.ApplicationThemeName uses the living theme.
private
void
AddinModule_OfficeColorSchemeChanged(
object
sender,
OfficeColorScheme theme)
{
string
themeName =
string
.Format(
"Office2010{0}"
,
theme);
if
(!
this
.themes.ContainsKey(themeName))
{
switch
(theme)
{
case
OfficeColorScheme.Black:
this
.themes.Add(themeName,
Activator.CreateInstance<Office2010BlackTheme>());
break
;
case
OfficeColorScheme.Blue:
this
.themes.Add(themeName,
Activator.CreateInstance<Office2010BlueTheme>());
break
;
case
OfficeColorScheme.Silver:
this
.themes.Add(themeName,
Activator.CreateInstance<Office2010SilverTheme>());
break
;
}
}
ThemeResolutionService.ApplicationThemeName = themeName;
}
Hope it helps others
Regards from Leipzig
Holger Boskugel