Im trying to set the background borderbrush on a simple textbox when the textbox has focus.
This is my style
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="False">
<Setter Property="BorderBrush" Value="Blue"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="Red"/>
<!--<Setter Property="Background" Value="Red"/>-->
</Trigger>
IsFocus = False works correctly however the trigger for true doesnt.
I have commented out the background setter but if I uncomment it I can see that the background is been set to red.
What do I need to do differently to change the border colour when the textbox has focus?
Thank you.
If your BorderThickness to “1” (default) then the focussed style you get is the standard 3D one of the control. You could restyle the control using a contenttemplate but a simple (although not the most elegant solution) would be to simply set the border thickness to something other than “1” as i’ve done in the sample below.