The BorderBrush property of the TextBox sets a brush to draw
the border of a TextBox. You may use any brush to fill the border. The code
snippet in Listing 3 uses a linear gradient brush to draw the border with a
combination of red and blue color.
<TextBox.BorderBrush>
<LinearGradientBrush StartPoint="0,0"
EndPoint="1,1" >
<GradientStop Color="Blue"
Offset="0" />
<GradientStop Color="Red"
Offset="1.0" />
</LinearGradientBrush>
</TextBox.BorderBrush>
Listing 3
The Background and Foreground properties of the TextBox set
the background and foreground colors of a TextBox. You may use any brush to
fill the border. The following code snippet uses linear gradient brushes to
draw the background and foreground of a TextBox.
<TextBox.Background>
<LinearGradientBrush StartPoint="0,0"
EndPoint="1,1" >
<GradientStop Color="Blue"
Offset="0.1" />
<GradientStop Color="Orange"
Offset="0.25" />
<GradientStop Color="Green"
Offset="0.75" />
<GradientStop Color="Red"
Offset="1.0" />
</LinearGradientBrush>
</TextBox.Background>
<TextBox.Foreground>
<LinearGradientBrush StartPoint="0,0"
EndPoint="1,1" >
<GradientStop Color="Orange"
Offset="0.25" />
<GradientStop Color="White"
Offset="1.0" />
</LinearGradientBrush>
</TextBox.Foreground>