Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1175
Changing Selected Background and Foreground color in TabItemEx
posted

How do you change the selected tab background and foreground colors.  I have the XamTabControl setup the way I want except I cannot figure out how to change the selected colors.

  • 54937
    Verified Answer
    Offline posted

    The look of the elements are based on their templates so usually the best place to check where an element gets is brushes from is by looking at the xaml. We include the default xaml with the product in the DefaultStyles directory. In the case of the selected tab, there are controltemplate triggers in the various templates for TabItemEx  (currently there is are 4 different templates that may be used - aero, generic, office2k7black and office2k7blue - depending the Theme setting or current OS theme). When IsSelected is true, the Background is set to a brush whose key is igWindows:PrimitivesBrushKeys.TabItemIsSelectedTopCenterFillKey (the brush used may be different depending on the tabstripplacement) so if you want to change the selected background color then you could include a brush in the Resources with this key. e.g.

    <igWindows:XamTabControl.Resources>
      <SolidColorBrush Color="Yellow" x:Key="{x:Static igWindows:PrimitivesBrushKeys.TabItemIsSelectedTopCenterFillKey}" />
    </igWindows:XamTabControl.Resources>

    Note in the case of the Aero theme, the default Background for the XamTabControl itself uses this resource key so if you don't want the content area to pick up this color you may want to set the Background of the XamTabControl itself to a different brush.

    With regards to Foreground that is an attached property so setting it on the TabItem will affect the TabItem's header unless it's been set in the Style/Template for the TabItem (which in looking at the default xaml seems to happen in the Office2k7 themes where the foreground uses a key with a value of igWindows:PrimitivesBrushKeys.TabItemIsSelectedTextFillKey.