Foreground not working on multiple controls

6 posts, 0 answers
  1. Derek
    Derek avatar
    4 posts
    Member since:
    Jan 2011

    Posted 21 Jun 2012 Link to this post

    Hello,

    I'm trying to change the foreground on a few different controls - one being a RadTabItem.  However, they are displaying white.  Prior to the last upgrade these were working.  Below is some sample code.

    UserRadTabItem = new RadTabItem                 
    {                     
        Tag = "tabUsers",                     
        Header = "Users",                     
        IsSelected = true,                     
        Margin = new Thickness(0, 5, 5, 0),                     
        Height = 40,                     
        Width = 60,                     
        FontSize = 13,                     
        Foreground = new SolidColorBrush(Colors.Green),                     
        Cursor = Cursors.Hand,                 
    };

    Thanks,
    Derek
  2. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 22 Jun 2012 Link to this post

    Hi Derek,

    Do you have a theme set on the controls?

    Lancelot
  3. Derek
    Derek avatar
    4 posts
    Member since:
    Jan 2011

    Posted 22 Jun 2012 Link to this post

    Yes, metro.

    Derek
  4. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 22 Jun 2012 Link to this post

      There is your problem. Once you are using a theme manager, you can't override a particular foreground property. The Style takes precedence. You can however leverage the new implicit theming system of the controls.You have a few options, the quickest way would be to set a certain palette at runtime. Learn how to do that here.

    In your situation I would just modify the existing Metro theme. You can do that by following these directions.

    I hope I helped clear this up for you, good luck.

    Lancelot
  5. Derek
    Derek avatar
    4 posts
    Member since:
    Jan 2011

    Posted 22 Jun 2012 Link to this post

    Thanks a lot.  Was this changed with the latest upgrade becuase it used to work?  Seems strange you can't override a style at the page level.

    Derek
  6. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 22 Jun 2012 Link to this post

    Derek,

    Yes, the changes made to the theming mechanisms started with Q1 SP1 update and Q2 release. This document describes more about the changes and the new abilities. It gives you much more flexibility throughout your application, you can set a custom theme to just one control or change it at runtime.

    This way, instead of having to change all of the attributes of a control in an event handler (each time on each page). You can just set it once to change everything on that particular control. You only have to set the colors once and it will work application-wide where you want it to.

    Lancelot
Back to Top