title: In code-behind how can I override tabitem colors set by an application-wide theme?
body: <p>I change the background color of my TabItem conditionally in code behind. This works fine as long as no theme is set in the App.xaml. <strong>How can I change colors of a TabItem (in code) while keeping an application-wide theme?</strong></p>
  
  <p>Background:</p>
  
  <p>I'm using a free WPF theme from <a href="http://www.nukeation.com/free.aspx" rel="nofollow noreferrer">Nukeation Reuxables</a>. The theme is set in the Application.Resources section of my App.xaml: </p>
  
  <p><code>&lt;ResourceDictionary Source="/ReuxablesLegacy;component/Edge.xaml" /&gt;</code>. </p>
  
  <p>I'm trying to conditionally set the background color of a TabItem in code behind:</p>
  
  <pre><code>MyTabItem.Background = new SolidColorBrush(Colors.Gray);
  </code></pre>
  
  <p>The background color changes if I remove or comment out the App.xaml line that sets the theme. Why does the theme break my code? I'm changing the tab color (as data is loaded) to show which tabs contain data.</p>
  
  <p>I'm aware that XAML and binding are typically used to change colors, but the solutions I've attempted seem overly complex. <a href="https://stackoverflow.com/questions/6845423/wpf4-using-xaml-binding-how-can-i-visually-alert-users-that-a-tab-contains-data">Here is my related StackOverflow question</a> seeking an all XAML and binding solution. The answers given just raised more questions which I haven't found answers to.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>The problem <strong>does not happen</strong> when changing the background of a button: </p>
  
  <p><code>button1.Background = new SolidColorBrush(Colors.Red);</code></p>
  
  <p>The button changes color as expected (while using an application-wide theme).</p>