title: How can you change the highlighted text color for a WPF TextBox?
body: <p>The WPF <code>TextBox</code> natively makes use of the System Highlight color for painting the background of selected text.  I would like to override this and make it consistent since it varies by OS/user theme.</p>
  <p>For <code>ListBoxItem</code>s, there is a <a href="http://blogs.msdn.com/wpfsdk/archive/2007/08/31/specifying-the-selection-color-content-alignment-and-background-color-for-items-in-a-listbox.aspx" rel="nofollow noreferrer">neat trick</a> (see below) where you can override the resource key for the <code>HighlightBrushKey</code> to customize the System Highlight color in a focused setting:</p>
  <pre><code>&lt;Style TargetType=&quot;ListBoxItem&quot;&gt;
      &lt;Style.Resources&gt;
          &lt;SolidColorBrush x:Key=&quot;{x:Static SystemColors.HighlightBrushKey}&quot;
                           Color=&quot;LightGreen&quot;/&gt;
      &lt;/Style.Resources&gt;
  &lt;/Style&gt;
  </code></pre>
  <p>The same trick does not work for the <code>TextBox</code> unfortunately.  Does anyone have any other ideas, besides &quot;override the <code>ControlTemplate</code>&quot;?</p>
  <p><a href="http://blogs.msdn.com/llobo/archive/2009/10/27/new-wpf-features-caretbrush-selectionbrush.aspx" rel="nofollow noreferrer">NOTE: This behavior appears to be added to WPF 4.</a></p>