Text color for disabled controls

5 posts, 0 answers
  1. Sergey Arutchev
    Sergey Arutchev avatar
    14 posts
    Member since:
    Sep 2009

    Posted 04 Dec 2009 Link to this post

    Hi,

    Is it possible to set (change style) text color for disabled control to 'normal' black? I need all parts of disabled control to look as we have it now but actual text to be black. Can it be changed on Theme level? (I need it for RadComboBox, RadDatePicker, RadMaskedTextBox).

    Thanks,
    Sergey
  2. Pana
    Admin
    Pana avatar
    748 posts

    Posted 08 Dec 2009 Link to this post

    Hi Sergey Arutchev,

    You can create a custom theme that is based on one of our existing themes and modify the xaml files from them in order to achieve that behavior. If you are new to our controls I suppose you will need some help creating the new theme. So if you tell me on which theme you have based your application I will create an example project for you.

    Greetings,
    Panayot
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Sergey Arutchev
    Sergey Arutchev avatar
    14 posts
    Member since:
    Sep 2009

    Posted 08 Dec 2009 Link to this post

    Hi Panayot,
     
    Thank you for your help. Examlpe project is exactly what I need. I'm using OfficeBlue Theme.

    Thanks,
    Sergey
  4. Pana
    Admin
    Pana avatar
    748 posts

    Posted 09 Dec 2009 Link to this post

    Hi Sergey Arutchev,

    I'm attaching the example solution. It has 3 projects:
    OfficeBlue, CustomTheme and OfficeBlue_CustomDisabledState

    The OfficeBlue is our theme that has all the xaml. You may need it to add or modify other controls but it's not actually used or referenced anywhere.

    The CustomTheme is the custom theme project. It has a Generic.xaml resource dictionary that merges the xaml that will be included in the theme. Also in the custom theme there are copies from OfficeBlue for the Calendar.xaml, ComboBox.xaml and MaskedTextBox.xaml. These three are added to the Generic.xaml as merged dictionaries. The themes in these 3 files are modified. You can search for the word "CHANGE:" in them to see what's the difference.

    The OfficeBlue_CustomDisabledState is a project that has example with the 3 controls and a checkbox that enable/disable them. In it's App.xaml.cs it creates a Theme based on the Generic from the CustomTheme project and uses it as ApplicationTheme. These line does the work:

    // Set your custom theme as application theme prior to initializing any controls...
    Telerik.Windows.Controls.StyleManager.ApplicationTheme =
        new Telerik.Windows.Controls.Theme(new Uri("/CustomTheme;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute));

    Note that OfficeBlue_CustomDisabledState has reference to the CustomTheme project. Also they have reference to the dlls for Telerik.Windows.Controls and Telerik.Windows.Controls.Input. If you add more controls to your project you will need to include the corresponding dlls. 

    In the example project the disabled state is removed from the VisualStateManagers. The controls use x:Name="DisabledVisual" element that is placed on top of the control and is somewhat transparent. If you want to make the controls shallow but keep the text black you may need to placed several DisabledVisuals over the buttons and backgrounds but behind the TextBlocks. if you are new to styling and templating in xaml you will need additional help.

    One of the benefits of having custom theme is that it won't include all the xaml files from Office_Blue so it's download size will get smaller. Right now it has only 3 Controls from input so you will need to add the xaml from the default Office_Blue theme for the controls you will use in your application.

    Best wishes,
    Panayot
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Sergey Arutchev
    Sergey Arutchev avatar
    14 posts
    Member since:
    Sep 2009

    Posted 09 Dec 2009 Link to this post

    Hi Panayot,
     
    Thank you. I'll try it.

    Thanks,
    Sergey
Back to Top