Reputation: 2165
Is it possible to set application wide theme from XAML in Telerik? There is only a code-behind example. I would like to set in in XAML and have a Metro theme in design-mode too.
Upvotes: 2
Views: 2124
Reputation: 5360
You could achieve this as follows:
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="SilverlightApplication.App">
<Application.Resources>
<telerik:MetroTheme x:Key="Theme" IsApplicationTheme="True"/>
</Application.Resources>
</Application>
Upvotes: 7
Reputation: 843
This did not work for me at first. It threw the follwoing exceptions:
{System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri, Type componentType)}
Set property 'Telerik.Windows.Controls.Theme.ApplicationThemeSetter' threw an exception. [Line: 53 Position: 70]
I tried declaring it in the App.xaml and the Generic.xaml but the same result.
I also tried to set the theme in the XAML like:
<t:RadGridView t:StyleManager.Theme="Windows8Theme" ..../>
But this has no affect.
NOTE: I'm using 2012's Q3
I solved the problem eventually. You have to include the theme DLL. So in my case I wanted to use the Windows8Theme, I needed to add a reference to the Telerik.Windows.Themes.Windows8.dll. It would be helpful if Telerik's code throw an exception saying as much, but "hey", that's just me.
Upvotes: 2