Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF theme windows controls to match Telerik ones

We have a project that mainly uses Telerik WPF controls. Unfortunately there are some show stopper bugs in some of the controls (mainly the tab control) that means we needed to drop the windows equivalent in instead. Is there anyway to get the windows controls to style like the telerik ones as currently they don't match at all. I have been told you can do this but cannot find anything on-line about it.

Thanks.In.Advance

like image 829
Nick Avatar asked Jan 19 '11 15:01

Nick


2 Answers

OK, this question has already been "answered", but I also found it incredibly hard to find any information, so for those who follow:

Setting the theme for the Telerik controls is easy, eg

Telerik.Windows.Controls.StyleManager.ApplicationTheme = new Telerik.Windows.Controls.SummerTheme();

but what you also have to do is create a resources file that sets the theme for all the windows controls, eg

<ResourceDictionary 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"                    
                    >

    <Style TargetType="TextBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:SummerTheme, ElementType=TextBox}}" />
    <Style TargetType="Button" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:SummerTheme, ElementType=Button}}" />
    <Style TargetType="ListBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:SummerTheme, ElementType=ListBox}}" />
    <Style TargetType="CheckBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:SummerTheme, ElementType=CheckBox}}" />
    <Style TargetType="PasswordBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:SummerTheme, ElementType=PasswordBox}}" />
    <Style TargetType="ScrollViewer" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:SummerTheme, ElementType=ScrollViewer}}" />

Then you either add it to the app's resources by placing a line in your app.xaml:

<ResourceDictionary Source="Resources/Windows_SummerTheme.xaml" />

or by adding it in code:

Application.Current.Resources.MergedDictionaries.Add("./Resources/Windows_SummerTheme.xaml");

Obviously you can then create a file for each theme and use a case statement so the user can skin the app from a menu.

Hope this helps!

like image 188
SteveCav Avatar answered Sep 30 '22 02:09

SteveCav


Answer

I managed to find this out from the person that originally told me for anyone having the same problem.

like image 21
Nick Avatar answered Sep 30 '22 02:09

Nick