Apply Theme in TextBox

9 posts, 1 answers
  1. Eduardo
    Eduardo avatar
    15 posts
    Member since:
    Mar 2009

    Posted 03 Apr 2009 Link to this post

    How to Apply the "RadThemes" in Controls as a TextBox?
  2. Answer
    Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 03 Apr 2009 Link to this post

    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.
  3. DevCraft banner
  4. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 26 Jan 2012 Link to this post

    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?


  5. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 30 Jan 2012 Link to this post

    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 >>

  6. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 31 Jan 2012 Link to this post

    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

  7. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 31 Jan 2012 Link to this post

    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 >>

  8. Aaron
    Aaron avatar
    9 posts
    Member since:
    Mar 2011

    Posted 02 Aug 2012 Link to this post

    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?
  9. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 03 Aug 2012 Link to this post

    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.

  10. Carlos Sesma
    Carlos Sesma avatar
    29 posts
    Member since:
    Dec 2008

    Posted 11 Oct 2012 Link to this post

    I changed the sample provided to be use with Q1 2010 and Silverlight 4,
    it does not change the style in the Textbox.
    thanks.
Back to Top
DevCraft banner