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

Apply Theme in TextBox

8 Answers 166 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Eduardo
Top achievements
Rank 1
Eduardo asked on 03 Apr 2009, 02:49 PM
How to Apply the "RadThemes" in Controls as a TextBox?

8 Answers, 1 is accepted

Sort by
0
Accepted
Kaloyan
Telerik team
answered on 03 Apr 2009, 03:50 PM
Hello Eduardo,

Actually, our themes provide styles for some of the standard controls, however, there is no style for the textbox control at the moment. We will consider enhancing the range of standard controls that are stylized by our themes for the upcoming Q2 release due in the summer.

Regards,
Kaloyan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
HDC
Top achievements
Rank 1
answered on 26 Jan 2012, 07:59 AM
This is an old item, but i notice that there still is no support for the textbox in the Expression Dark theme.

Because of this the carret in the textbox stays black, which makes it difficult to see. Changing the carret brush manually has a nasty side effect in our code that it will sometimes simply disappear (i suppose it gets the same color as the textbox itself.

Is this a bug in the Expression dark theme?


0
Vanya Pavlova
Telerik team
answered on 30 Jan 2012, 04:47 PM
Hello Peter,

 

You may simply set the CaretBrush of the TextBox to match the corresponding default Foreground for Expression_Dark theme and everything will work as expected:


<TextBox CaretBrush="#FFd2d2d2" Width="150" FontSize="26" telerik:StyleManager.Theme="Expression_Dark"/>


Can you verify how this works for you? 



Regards, 
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
HDC
Top achievements
Rank 1
answered on 31 Jan 2012, 08:15 AM

Hi Vanya,

Surely this will work. I'm already applying this technique.But in fact this means that we are unable to let the user switch themes as we "hard code" every TextBlock control to use one theme.

I also tried this (in app.xaml) but it's not working (surprisingly, it does work for less frequently used controls like a CheckBox):

...

<telerik:Expression_DarkTheme IsApplicationTheme="True" x:Key="Theme" />

<Style TargetType="TextBlock" telerik.StyleManager.BasedOn="{StaticResource Theme}">

...

Why is this not working for a very common control like the textbox or is there a more general approach so i am able to provide the possibility to switch themes on the fly, and most importantly, not having to set the CaretBrush on every textbox control?

Best Regards,

Peter

0
Vanya Pavlova
Telerik team
answered on 31 Jan 2012, 06:28 PM
Hello Peter,

 
I would like to shed some light on that matter. Keep in mind that the Telerik themes can be applied to the following native Silverlight controls:


1.System.Windows.Button
2.System.Windows.CheckBox
3.System.Windows.ListBox
4.System.Windows.RadioButton
5.System.Windows.ScrollViewer
6.System.Windows.PasswordBox
7.System.Windows.RepeatButton
8.System.Windows.TextBox


The TextBlock is not included in this list, since an implicit style targeted at TextBlock will style all text elements within your application. Setting an application wide theme will be evaluated at runtime.
When you apply the theme at runtime indeed only RadControls will be styled - not the native ones, which are being supported by our theming mechanism. If you want to style these native controls based on the current application theme you should manually set the corresponding theme, as shown below: 

App.xaml:

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             x:Class="RadTest.App"
             >
    <Application.Resources>
        <Style TargetType="TextBox">
              <Setter Property="CaretBrush" Value="#FFD2D2D2"/>
       </Style>
    </Application.Resources>
</Application>


App.xaml.cs:

public App()
      {
          this.Startup += this.Application_Startup;
          this.Exit += this.Application_Exit;
          this.UnhandledException += this.Application_UnhandledException;
          StyleManager.ApplicationTheme = new Expression_DarkTheme();
          InitializeComponent();
         StyleManager.SetBasedOn(((Style)Current.Resources[typeof(TextBox)]), StyleManager.ApplicationTheme);
      }


Will you verify how this works for you? 


Greetings,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Aaron
Top achievements
Rank 1
answered on 03 Aug 2012, 03:44 AM
I'm theming my controls "the Telerik way" and find that the MS controls are not getting their themes applied. I tried your approach and the application would throw and exception "Object reference not set to an instance of an object." at the line "StyleManager.SetBasedOn(...)". Can you help?
0
Vanya Pavlova
Telerik team
answered on 03 Aug 2012, 07:47 AM
Hi Aaron,

 

I have tried to reproduce this exception, however I was not able to. Can you point us to the exact version of our controls you are currently using? You may also use the attached project, which I used for testing for further reference. Feel free to modify it in the way you need and send it back to us as attachment in a new support ticket.   




All the best,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Carlos Sesma
Top achievements
Rank 1
answered on 11 Oct 2012, 04:09 PM
I changed the sample provided to be use with Q1 2010 and Silverlight 4,
it does not change the style in the Textbox.
thanks.
Tags
General Discussions
Asked by
Eduardo
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
HDC
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Aaron
Top achievements
Rank 1
Carlos Sesma
Top achievements
Rank 1
Share this question
or