Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:31:45+00:00 2026-06-01T11:31:45+00:00

I have a TabControl, and among other tabs I have one called Errors. I

  • 0

I have a TabControl, and among other tabs I have one called “Errors”. I need its header foreground to become red when a certain property called “ErrorsExist” is set to true. Here is my code:

           <TabControl >
            <TabControl.Resources>
                <conv:ErrorsExistToForegroundColorConverter x:Key="ErrorsExistToForegroundColorConverter"/>

                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <TextBlock Foreground="{Binding  Path=ErrorsExist, Converter={StaticResource ErrorsExistToForegroundColorConverter}}" Text="{Binding}"/>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.Resources>

            <TabItem x:Name="ErrorsTab" Header="Errors">

Here is my Converter:

    public class ErrorsExistToForegroundColorConverter: IValueConverter
{

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
       switch ((bool)value)
       {
          case true:
             return Brushes.Red;
          case false:
             return Brushes.Black;
          default:
             return Binding.DoNothing;
       }
    }

I have two problems with this.

First of all, this will set all tab headers to red, and I need only to do it for the ErrorsTab tab.

Second, It just doesn’t work. I mean, the Convert() method of the converter is never called. Could you please help me with this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:31:47+00:00Added an answer on June 1, 2026 at 11:31 am

    Assign the style only to the TabItem that you’d like to change and better use a DataTrigger for this simple task:

    <TabItem x:Name="ErrorsTab" Header="Errors">
        <TabItem.Style>
          <Style TargetType="{x:Type TabItem}">
            <Style.Triggers>
              <DataTrigger Binding="{Binding ErrorsExist}" Value="True">
                  <Setter Property="Foreground" Value="Red"/>
              </DataTrigger>
             </Style.Triggers>
           </Style>
        </TabItem.Style>
      </TabItem>
    

    EDIT:

    Problem is that the TabItem Header doesn’t inherit the DataContext of the parent TabItem.
    If you want to get this to work with the converter set the TabHeader DataContext manually:

              <TextBlock DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabItem}}}" 
                         Foreground="{Binding ErrorsExist,Converter={StaticResource ErrorsExistToForegroundColorConverter}}" Text="{Binding}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that extends TabControl, basically to have one with the tabs
I have TabControl. I added it to tabpages. To one of them(tpTags) I dynamically
I got a strange problem. I have a tabcontrol and 3 tabs. On every
I'm trying to enable tabs functionality in the WebBrowser control. I have a TabControl
I have the next problem: TabControl has three TabPages. Every TabPage has its own
I have a TabControl with two tabs containing lists that should always be scrolled
I'm trying to do the following thing: I have a TabControl with several tabs.
I have tabcontrol component on my form. After I put XPManifest, its color became
I have a TabControl which looks like this: <TabControl> <TabItem> <TabItem.Header> <StackPanel Orientation=Horizontal> <Canvas
I have a TabControl with multiple pages. On one page, I just have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.