I would like to color a control in exactly the same color like is the default TextBox
's mouse over color (preferably theme-aware). e.g.
<Rectangle Fill={x:Static WhatDoIPutHere}/>
Under which key/resource can I access the color? In my current system it appears to be the #ff7eb4ea
light blue, but none of the *Highlight*, *Control* or *Border* System Colors seems to be of that value.
You're correct! MouseOver Border
color is #FF7EB4EA
; which is under TextBox.MouseOver.Border
key. I don't think you'll be able to access these Resources from outside. You can get these details from default ControlTemplate
for TextBox
. Which is
<SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
<SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
<SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
If you using Blend for Visual Studio, refer this to know how to access default Templates
of any control. If you're using Visual Studio, you can check this.