WPF SystemColors: color of TextBox border WPF SystemColors: color of TextBox border wpf wpf

WPF SystemColors: color of TextBox border


You might try using Microsoft.Windows.Themes.ListBoxChrome instead of the Border; that's what the default template for TextBox uses:

<ControlTemplate TargetType="TextBoxBase"                  xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">    <mwt:ListBoxChrome Name="Bd" SnapsToDevicePixels="True">        <ScrollViewer Name="PART_ContentHost"                       SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />    </mwt:ListBoxChrome>    <ControlTemplate.Triggers>        <Trigger Property="UIElement.IsEnabled" Value="False">            <Setter TargetName="Bd" Property="Panel.Background"                     Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />            <Setter Property="TextElement.Foreground"                     Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>        </Trigger>    </ControlTemplate.Triggers></ControlTemplate>

You should be able to use just ListBoxChrome instead of Border rather than re-templating TextBox to match the code you presented.


I was able to get it programatically with:

TextBox.BorderBrush = SystemColors.ControlDarkBrush;


To anyone that is looking for a list of Brushes and what their colors will look like with different themes/OS

I would look here: http://blogs.msdn.com/b/wpf/archive/2010/11/30/systemcolors-reference.aspx