I am attemtping to have my application switch from a default theme of Visual Studio 2013 Dark to the Windows 8 Touch during runtime. The Visual Studio theme applies correctly but when I attempt to switch the theme dynamically to the Touch theme I get the following error: Cannot find resource named 'ButtonIconForeground_MouseOver'. Resource names are case sensitive. I understand what the error is but I don't understand why it is happening. I am using the following Telerik DLLs:
Telerik.Windows.Controls
Telerik.Windows.Controls.Data
Telerik.Windows.Controls.Docking
Telerik.Windows.Controls.Navigation
Telerik.Windows.Controls.Input
Telerik.Windows.Data
This is my code to apply the default Visual Studio 2013 Dark theme:
Here is where I apply the Windows 8 Touch theme:
Telerik.Windows.Controls
Telerik.Windows.Controls.Data
Telerik.Windows.Controls.Docking
Telerik.Windows.Controls.Navigation
Telerik.Windows.Controls.Input
Telerik.Windows.Data
This is my code to apply the default Visual Studio 2013 Dark theme:
<
Application
x:Class
=
"Mantis.Client.App"
xmlns:resources
=
"clr-namespace:Mantis.Client.Resources"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
>
<
Application.Resources
>
<
ResourceDictionary
>
<!--These theme resources are here as defaults-->
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"/Themes/VisualStudio/System.Windows.xaml"
/>
<
ResourceDictionary
Source
=
"/Themes/VisualStudio/Telerik.Windows.Controls.xaml"
/>
<
ResourceDictionary
Source
=
"/Themes/VisualStudio/Telerik.Windows.Controls.Data.xaml"
/>
<
ResourceDictionary
Source
=
"/Themes/VisualStudio/Telerik.Windows.Controls.Docking.xaml"
/>
<
ResourceDictionary
Source
=
"/Themes/VisualStudio/Telerik.Windows.Controls.Input.xaml"
/>
<
ResourceDictionary
Source
=
"/Themes/VisualStudio/Telerik.Windows.Controls.Navigation.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
<
HierarchicalDataTemplate
x:Key
=
"MenuItemTemplate"
ItemsSource
=
"{Binding Items}"
>
<
TextBlock
Text
=
"{Binding Text}"
/>
</
HierarchicalDataTemplate
>
<
Style
x:Key
=
"MenuStyle"
TargetType
=
"telerik:RadMenuItem"
BasedOn
=
"{StaticResource RadMenuItemStyle}"
>
<
Setter
Property
=
"IsCheckable"
Value
=
"{Binding IsCheckable}"
/>
<
Setter
Property
=
"IsChecked"
Value
=
"{Binding IsChecked, Mode=TwoWay}"
/>
<
Setter
Property
=
"IsSeparator"
Value
=
"{Binding IsSeparator}"
/>
<
Setter
Property
=
"IsEnabled"
Value
=
"{Binding IsEnabled}"
/>
<
Setter
Property
=
"StaysOpenOnClick"
Value
=
"{Binding StaysOpenOnClick}"
/>
<
Setter
Property
=
"Icon"
Value
=
"{Binding Image}"
/>
</
Style
>
</
ResourceDictionary
>
</
Application.Resources
>
</
Application
>
public
partial
class
App : Application
{
private
MantisBootstrapper _bootstrapper;
protected
override
void
OnStartup(StartupEventArgs e)
{
Telerik.Windows.Controls.VisualStudio2013Palette.LoadPreset(Telerik.Windows.Controls.VisualStudio2013Palette.ColorVariation.Dark);
base
.OnStartup(e);
this
._bootstrapper =
new
MantisBootstrapper();
this
._bootstrapper.Run();
}
protected
override
void
OnExit(ExitEventArgs e)
{
this
._bootstrapper.Shutdown();
base
.OnExit(e);
}
}
Here is where I apply the Windows 8 Touch theme:
private
void
RadMenuItem_Click(
object
sender, Telerik.Windows.RadRoutedEventArgs e)
{
App.Current.Resources.MergedDictionaries.Clear();
App.Current.Resources.MergedDictionaries.Add(
new
Telerik.Windows.Controls.Windows8TouchResourceDictionary());
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary { Source =
new
Uri(
"/Themes/Touch/System.Windows.xaml"
, UriKind.Relative) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary { Source =
new
Uri(
"/Themes/Touch/Telerik.Windows.Controls.xaml"
, UriKind.Relative) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary { Source =
new
Uri(
"/Themes/Touch/Telerik.Windows.Controls.Data.xaml"
, UriKind.Relative) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary { Source =
new
Uri(
"/Themes/Touch/Telerik.Windows.Controls.Docking.xaml"
, UriKind.Relative) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary { Source =
new
Uri(
"/Themes/Touch/Telerik.Windows.Controls.Input.xaml"
, UriKind.Relative) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary { Source =
new
Uri(
"/Themes/Touch/Telerik.Windows.Controls.Navigation.xaml"
, UriKind.Relative) });
}