Custom Colors for a TextBox

njsokalski

Well-known member
Joined
Mar 16, 2011
Messages
102
Programming Experience
5-10
I have a TextBox in my App for which I want to customize the colors. At the moment, I am using the following Style:

<Style x:Key="EditPlayerStyle" TargetType="TextBox">
<Setter Property="Background" Value="Blue"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontFamily" Value="Comic Sans MS"/>
<Setter Property="FontSize" Value="36"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Width" Value="260"/>
</Style>

This looks great while the user is not editing the text, but while the user is editing the text, the background changes to white, but the foreground remains white as well, therefore making the text invisible. I realize that I could change the foreground using GotFocus and LostFocus, but what I really want is to be able to control the background, because I want the TextBox to look the same while the user is editing it as it does when they are not (not to mention a TextBox with a white background looks ugly in my App). Is there any way I can control how a TextBox looks while it is being edited? Thanks.
 
Back
Top