This is a migrated thread and some comments may be shown as answers.

Setting a global default theme

3 Answers 491 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sid
Top achievements
Rank 1
Sid asked on 11 Dec 2008, 06:45 PM

Just starting out and trying to work through some of the learning curve struggles, but this one has me stumped.

I'm trying to set a default theme for my grids inside a resource dictionary, I've tried the app.xaml file but also without success.

Here's my code:
 <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">
<!-- Resource dictionary entries should be defined here. -->
<Style TargetType="{x:Type telerik:RadGridView}">
<Style.BasedOn>
<Style TargetType="{x:Type telerik:RadGridView}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type telerik:RadGridView}">
<AdornerDecorator>
<telerik:Theming.Theme>
<telerik:TelerikTheme/>
</telerik:Theming.Theme>
</AdornerDecorator>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Style.BasedOn>
</Style>
</ResourceDictionary>

 

 

I started with an edit template and stripped out everything else.  When I run my application the grid is blank, actually it is blank in the designer as well as the Properties window.  If I add a x:Key value, the grid will reappear.  So it is applying my style in some fashion.  What am I missing?

Thanks,
-Sid Meyers.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Christopher
Top achievements
Rank 1
answered on 11 Dec 2008, 07:47 PM
Greetings!
   I'm not a Telerik support member, but this may be of interest to you.

   I've found that I can apply global themes  in the App.xaml like this:
<Application x:Class="WpfApplication3.App" 
    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" 
    StartupUri="Window1.xaml"
    <Application.Resources> 
        <Style TargetType="{x:Type telerik:RadGridView}"
            <Setter Property="telerik:Theming.Theme" Value="Telerik" /> 
        </Style> 
    </Application.Resources> 
</Application> 
 

However... This throws an error in the designer but works correctly at run time.  According to the Telerik documentation at : http://www.telerik.com/help/wpf/gridview-styling-using-themes.html  this should work, so I'm not sure what's up here.

If you follow the example code to the letter, you still get a design error stating that the value of the theme property cannot be a string.

Maybe an error in the Q3 release?

Chris
0
Sid
Top achievements
Rank 1
answered on 11 Dec 2008, 08:02 PM
Chris,

Thanks for the reply.  It works but definitely a PITA!  Guess I'll just have to comment out the section while I'm trying to develop for now.

-Sid.
0
Milan
Telerik team
answered on 12 Dec 2008, 02:37 PM
Hi Sid,

Chis's suggestion is valid and represents the best way to change the default theme of our grid.
I can suggest a minor modification that resolves the issue with the design time error. Instread of setting the value of the Theming.Theme property as string you can set the theme like this:

<Style TargetType="{x:Type telerik:RadGridView}">  
    <Setter Property="controls:Theming.Theme">  
        <Setter.Value> 
            <controls:TelerikTheme/> 
        </Setter.Value> 
    </Setter> 
</Style> 

That way we are directly providing a Theme object as value and the error will not appear.
We are curently lookin into the exact cause of this error.

Hope this helps.

Best wishes,
Milan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Sid
Top achievements
Rank 1
Answers by
Christopher
Top achievements
Rank 1
Sid
Top achievements
Rank 1
Milan
Telerik team
Share this question
or