码迷,mamicode.com
首页 > Windows程序 > 详细

WPF TextBox提示文字设定

时间:2017-09-21 13:41:27      阅读:881      评论:0      收藏:0      [点我收藏+]

标签:setter   block   div   enter   ack   set   code   ica   preview   

 

WPF TextBox框提示文字,鼠标划入提示文字消失

<TextBox
Width="248"
VerticalContentAlignment="Center"
BorderThickness="0"
CaretBrush="White">
<TextBox.Resources>
<VisualBrush
x:Key="HintText"
AlignmentX="Left"
Opacity="0.5"
Stretch="None"
TileMode="None">
<VisualBrush.Visual>
<TextBlock
FontSize="12"
Foreground="White"
Text="{DynamicResource MsgUser}" />
</VisualBrush.Visual>
</VisualBrush>
</TextBox.Resources>
<TextBox.Style>
<Style TargetType="TextBox">
<Setter Property="Background" Value="Transparent" />
<Style.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource HintText}" />
</Trigger>
<Trigger Property="Text" Value="">
<Setter Property="Background" Value="{StaticResource HintText}" />
</Trigger>
<Trigger Property="IsFocused" Value="true">
<Setter Property="Background" Value="Transparent" />
</Trigger>
<!--<EventTrigger RoutedEvent="TextBox.PreviewTextInput" />-->
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>

 

WPF TextBox提示文字设定

标签:setter   block   div   enter   ack   set   code   ica   preview   

原文地址:http://www.cnblogs.com/amwuau/p/7562284.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!