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

Overriding theme styles

1 Answer 142 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 03 Feb 2012, 01:04 AM
Hi,


I'm wondering if it's possible to use a Telerik theme (Expression Dark) while overriding certain theme properties. For example, I find that the Expression Dark theme looks good overall, but I'd like the caret in a TextBox to be white rather than black.

I tried the following in my application resource dictionary:

<Style TargetType="TextBox">
    <Setter Property="telerik:StyleManager.Theme" Value="Expression_Dark" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="CaretBrush" Value="White" />
</Style>

This uses an implicit style to apply the Expression Dark theme to all text boxes. I found that when I did this, the content became centered for some reason; so I also added the HorizontalContentAlignment setter.

When I use the above style, the CaretBrush setter has no effect - the caret remains black. I can set the CaretBrush explicitly on each TextBox element, but I was hoping to apply the same style to all text boxes automatically.

Is there a better way to do this? We are still using Silverlight 4 - I'm not sure if that makes a difference.

I guess another option would be to create a custom TextBox-derived control, and set the properties I want to change programmatically. Or should I investigate making a copy of the Expression Dark theme and modifying it?


Thanks for your help,
Richard

1 Answer, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 03 Feb 2012, 08:07 AM
Hi,


I ended up solving the problem by copying the control template from the Themes solution that comes with the Telerik controls installation. I didn't create a custom theme - I just copied the Telerik template from the theme into my own resource dictionary. I modified this copy, and I used the copy directly rather than applying the Telerik theme to my text boxes. I'm still using the Telerik theme for other control types, but I don't apply it to text boxes.

Also, I realized belatedly that it's not a good idea to use an implicit style to set telerik:StyleManager.Theme. I'm sure the style manager has to reset the implicit style at runtime, and I guess that blows away the telerik:StyleManager.Theme property that brought in the style manager in the first place.

This was causing my Visual Studio to crash. I switched to use the StyleManager.BasedOn() approach described by Vanya Pavlova here:
http://www.telerik.com/community/forums/silverlight/general-discussions/expression-dark-theme-on-non-telerik-controls.aspx 
It's working fine for me now.


Thanks,
Richard


Tags
General Discussions
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Share this question
or