Accessing Telerik theme resource id

10 posts, 0 answers
  1. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 17 Oct 2012 Link to this post

    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
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 22 Oct 2012 Link to this post

    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.

  3. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 22 Oct 2012 Link to this post

    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

  4. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 22 Oct 2012 Link to this post

    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.

  5. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 22 Oct 2012 Link to this post

    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
  6. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 22 Oct 2012 Link to this post

    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.

  7. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 22 Oct 2012 Link to this post

    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
  8. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 22 Oct 2012 Link to this post

    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.

  9. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 22 Oct 2012 Link to this post

    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
  10. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 25 Oct 2012 Link to this post

    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.

Back to Top