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

Accessing Telerik theme resource id

9 Answers 322 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 17 Oct 2012, 03:23 PM
Hi,

I use VS2008 and Telerik V2012.2.912.35 and in our project we have a resource file that contain specific style for our controls and I would like to use Telerik resource keys in our style (for Telerik theming purpose) but I don't know how, here is my style and the Telerik keys I want to use:

    <Style x:Key="RadExpander" TargetType="{x:Type telerik:RadExpander}">       
        <Setter Property="Background" Value="{StaticResource Item_AlternateBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder_Normal}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect />
            </Setter.Value>
        </Setter>
    </Style>

Thank's

9 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 22 Oct 2012, 02:06 PM
Hi Oliver,

I am not sure what is your scenario and this is why I don't know what to advice you. Basically the Telerik resource keys are used internally only by the StyleManager to apply the proper styles for each Telerik theme. However, you only need such keys in your styles in case you create a custom theme.

Otherwise, you should be able to apply the RadExpander style you pasted out-of-the-box in your application. It will be applied on the default style/template of the control and you don't have to add anything else to make sure that the style is properly applied.

Still, if I'm missing something, please let me know.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Oliver
Top achievements
Rank 1
answered on 22 Oct 2012, 02:23 PM
Hi Tina,

actually in our Solution we have many projects. One of our projects is called "Resources" and we have a file inside of it called "Neuron-CustomStyles.xaml" and we have the following piece of code inside of it:

<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 x:Key="RadExpander" TargetType="{x:Type telerik:RadExpander}">       
        <Setter Property="Background" Value="{StaticResource Item_AlternateBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder_Normal}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect />
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>

In all of our projects, we need to change the RadExpander look and for this, we want to use existing Telerik resources keys for Telerik Theming purpose,  but it doesn't work. Each RadExpander should have the same look, we want to change the border and the background of the RadExpander so we want to use the existing resources keys of Telerik to preserve the theming colors. So, if we decide to use another theme in the future, we shouldn't have to care of the color we put in our resources.

Here is what we add in the main RadWindow of each of our projects:

    <telerik:RadWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="SignatureForm-Fr-Res.xaml" />
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Neuron-CustomStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>                       
        </ResourceDictionary>
    </telerik:RadWindow.Resources>

Thank's

0
Tina Stancheva
Telerik team
answered on 22 Oct 2012, 02:44 PM
Hi Oliver,

Thank you for getting back to us and elaborating on your scenario. I think in this case, it is better to use implicit styles or in case you need to more thoroughly restyle the controls, follow the steps described in this tutorial.

Basically, in your solution, you can just remove the x:key property defined in the RadExpander style definition.

Please give this a try and let me know if it helps.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Oliver
Top achievements
Rank 1
answered on 22 Oct 2012, 03:14 PM
Hi Tina,

I removed the "x:key" and look at the enclosed picture to see the error I receive when I start my project.

Thank's
0
Tina Stancheva
Telerik team
answered on 22 Oct 2012, 03:17 PM
Hi Oliver,

You receive this error as the RadExpander style can't find the Item_AlternateBackground and ControlOuterBorder_Normal brush resources. Can you make sure that they are included in the Neuron-CustomStyles.xaml file?

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Oliver
Top achievements
Rank 1
answered on 22 Oct 2012, 03:21 PM
Hi Tina,

sorry if my explanations was not clear enought lolll

How I can include those Telerik resources in my Neuron-CustomStyles.xaml?!? Those resources reside in Telerik resource files!!!

Thank's
0
Tina Stancheva
Telerik team
answered on 22 Oct 2012, 04:15 PM
Hello Oliver,

You can get the style resources of all our controls under your installation directory either in the Themes folder or in the Themes.Implicit folder. You can open the theme you're using to base your style on and get the appropriate brushes and paste them into your Neuron-CustomStyles.xaml file.
 
Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Oliver
Top achievements
Rank 1
answered on 22 Oct 2012, 06:31 PM
Hi Tina,

is it possible to access direcly the key from Telerik files instead of having to duplicate the value into 2 separate files?

This way, if in the future we decide to change our Telerik theme, we shouldn't have to consider changing our code!!!

Thank's
0
Tina Stancheva
Telerik team
answered on 25 Oct 2012, 03:54 PM
Hi Oliver,

You can base your style on the Telerik default styles using the implicit styles approach described here.

However, if you need to create just one fairly simple style, as the one you posted here, then it's best to just copy/paste the resources you need from the Telerik ResourceDictionaries.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
General Discussions
Asked by
Oliver
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Oliver
Top achievements
Rank 1
Share this question
or