How to change color of WPF tab header on an custom event?


  • Hello,
    I have a tab control in WPF. In it, I have one of the tab item as Alarms.

    I want to change the tab header color of alarms tab on an event which is generated in WPF code behind.

    How to achieve it?

    Best Regards,
    Wednesday, November 26, 2008 5:38 AM

All replies

  • Assume the control looks like this,

    <TabControl x:Name="tabctrl" SelectionChanged="tabctrl_SelectionChanged">
            <TabItem x:Name="tabAlert1" Header="Alert 1"></TabItem>
            <TabItem x:Name="tabAlert2" Header="Alert 2"></TabItem>

    The above setup contains two tabitems.

    /// This is the event that is used to access the tabcontrol when the user changes his selection  of the tab.
    private void tabctrl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        if (tabctrl.SelectedIndex == 0)      

    /// Give your condition here so that u can change the header color of the tab items accordingly.
            tabAlert1.Background = Brushes.Blue;
            tabAlert2.Background = Brushes.Red;

    try this....


    Saturday, December 13, 2008 1:13 PM