如何在图片中自定义文本框?
答案 0 :(得分:0)
XAML
<TextBox BorderThickness="0,0,0,1" BorderBrush="Gray" Background="Transparent" GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus"/>
C#
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
var tb = (TextBox)sender;
tb.BorderBrush = Brushes.Black;
tb.BorderThickness = new Thickness(0, 0, 0, 2);
}
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
var tb = (TextBox)sender;
tb.BorderBrush = Brushes.Gray;
tb.BorderThickness = new Thickness(0, 0, 0, 1);
}