WPF输入框里面加文本提示

xml 复制代码
 <TextBox x:Name="txtSampleNo"  Width="265" Height="36" VerticalContentAlignment="Center"  HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"   >
     <TextBox.Resources>
         <VisualBrush x:Key="text1" Opacity="1" TileMode="None" AlignmentX="Left" Stretch="None">
             <VisualBrush.Visual>
                 <TextBlock Text="输入样品编号" FontSize="16" />
             </VisualBrush.Visual>
         </VisualBrush>
     </TextBox.Resources>
     <TextBox.Style>
         <Style TargetType="TextBox">
             <Style.Triggers>
                 <Trigger Property="Text" Value="{x:Null}">
                     <Setter Property="Background" Value="{StaticResource text1}"/>
                 </Trigger>
                 <Trigger Property="Text" Value="">
                     <Setter Property="Background" Value="{StaticResource text1}"/>
                 </Trigger>
             </Style.Triggers>
         </Style>
     </TextBox.Style>
 </TextBox>
相关推荐
bugcome_com1 天前
WPF 命令 ICommand 从原理到实战
后端·wpf·icommand
武藤一雄2 天前
WPF处理耗时操作的7种方法
microsoft·c#·.net·wpf
Venom842 天前
我的 WPF Powermill 工具
wpf
一念春风3 天前
证件照制作工具(WPF C#)
c#·wpf
He BianGu4 天前
【笔记】在WPF中GiveFeedbackEventHandler的功能和应用场景详细介绍
笔记·wpf
就是有点傻4 天前
WPF自定义控件-水晶球
wpf
He BianGu4 天前
【笔记】在WPF中QueryContinueDragEvent的详细介绍
笔记·wpf
He BianGu4 天前
【笔记】在WPF中QueryCursor事件的功能和应用场景详细介绍
笔记·wpf
He BianGu4 天前
【笔记】在WPF中CommandManager的功能和应用场景详细介绍
笔记·wpf
关关长语4 天前
HandyControl中Button图标展示多色路径
c#·.net·wpf·handycontrol