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

Accessing Telerik Theme Resources

3 Answers 121 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 30 Sep 2010, 04:28 PM
Hi,

I have implemented dynamic theming within my MVVM/Prism application, and for now I am utilising the built-in Telerik themes. When the theme is changed the required assembly is downloaded from the server and the styles are applied to the UI through my ViewModel that contains the current theme.

This all works perfectly and the controls where I have set the StyleManager.Theme="{Binding CurrentTheme.Theme}" property are updated dynamically. I have set up some custom control templates, such as the below for the RadExpander, and these templates also include colours. I would like the theme to be able to change the colours contained within the template (Background, Border etc.) as well if at all possible. I have tried moving the statically referenced brushes into the Expander.xaml project of the Theme, but the parser is unable to identify them. I have also tried moving the control templates themselves into the Expander.xaml resource dictionary, but again no luck:

<ControlTemplate x:Key="ExpanderHeaderTemplate" TargetType="Custom:RadExpanderHeader">
        <Grid Background="{TemplateBinding Background}">
            <Border Style="{StaticResource Border_GrayRoundedHeader}" Padding="5">
                <Grid>
                    <ContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Margin="{TemplateBinding Padding}" x:Name="content" VerticalAlignment="Center" VerticalContentAlignment="Center" Visibility="Visible" Opacity="1"/>
                    <Custom:RadExpanderDecorator x:Name="decorator" ExpandDirection="{TemplateBinding ExpandDirection}" IsPressed="{TemplateBinding IsPressed}" IsHighlighted="{TemplateBinding IsMouseOver}" IsExpanded="{TemplateBinding IsExpanded}" Margin="0,0,10,0" Template="{TemplateBinding DecoratorTemplate}" HorizontalAlignment="Right" VerticalAlignment="Center" />
                    <Rectangle x:Name="FocusDecorator" IsHitTestVisible="false" Opacity="0" StrokeThickness="0" Visibility="Collapsed"/>
                </Grid>
            </Border>
        </Grid>
    </ControlTemplate>


Is there a way I can apply custom control templates that utilise the Telerik theming mechanism?

Regards,
Chris

3 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 05 Oct 2010, 02:45 PM
Hello Chris,

When you create custom control templates for themed RadControls, the custom control template takes precedence.

Therefore, a possible approach towards your scenario is to create different custom themes for the controls instead of creating custom control templates. Here you can find more information about creating custom themes and choose the best suited approach for your scenario.

If you decide to use this approach, then you will be able to control the appearance of each RadControl in your application by binding the StyleManager.Theme property.

Best wishes,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris
Top achievements
Rank 1
answered on 05 Oct 2010, 02:56 PM
Hi Tina, thanx for coming back to me.

Can you explain in more detail how this approach would work? I have a base ViewModel that contains a CurrentTheme.Theme property and this is bound to all Telerik controls. As mentioned above I have some controls that are styled differently in terms of layout and colour, alongside some standard controls. I have custom theming working to change the theme at runtime via the StyleManager.Theme dependency property. How would this provide a means to change a controls appearance to something other than the default themed template for that control?

Here is a simple example to explain what I would like to do. Lets say I have 2 RadButton controls, one styled Red and one styled Blue. When the theme is changed I would like the Red RadButton to be Green and the Blue RadButton to be Orange. The colour of the RadButtons is being set using the Style property. Is there a way, using theming, that styling the look of individual controls with different Style properties can be done?

Many Thanx,
Chris
0
Tina Stancheva
Telerik team
answered on 08 Oct 2010, 01:53 PM
Hello Chris,

Thank you for clarifying your scenario. Unfortunately, there isn't a way to implement this functionality using the theming mechanism.

All the best,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Chris
Top achievements
Rank 1
Share this question
or