• WPF 带有提示文本的透明文本框


     1 <TextBox Text="{Binding SearchInfo, UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0"  MaxLength="20" BorderThickness="0">
     2                                 <TextBox.Resources>
     3                                     <VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.3" Stretch="None" AlignmentX="Center">
     4                                         <VisualBrush.Visual>
     5                                             <TextBlock FontStyle="Italic" Text="搜索"/>
     6                                         </VisualBrush.Visual>
     7                                     </VisualBrush>
     8                                 </TextBox.Resources>
     9                                 <TextBox.Style>
    10                                     <Style TargetType="TextBox">
    11                                         <Setter Property="Height" Value="25px"/>
    12                                         <Setter Property="VerticalContentAlignment" Value="Center"/>
    13                                         <Setter Property="HorizontalContentAlignment" Value="Center"/>
    14                                         <Setter Property="Background" Value="Transparent"/>
    15                                         <Style.Triggers>  
    16                                             <Trigger Property="Text" Value="{x:Null}">
    17                                                 <Setter Property="Background" Value="{StaticResource HelpBrush}"/>
    18                                             </Trigger>
    19                                             <Trigger Property="Text" Value="">
    20                                                 <Setter Property="Background" Value="{StaticResource HelpBrush}"/>
    21                                             </Trigger>
    22                                         </Style.Triggers>
    23                                     </Style>
    24                                 </TextBox.Style>
    25                             </TextBox>
  • 相关阅读:
    捡到一本<C++ Reference>
    题目1008:最短路径问题
    题目1014:排名
    题目1080:进制转换
    题目1081:递推数列
    题目1086:最小花费
    题目1076:N的阶乘
    题目1035:找出直系亲属
    在Mac上搭建Jenkins环境
    获取鼠标点击UGUI,先对于特定物体的相对坐标
  • 原文地址:https://www.cnblogs.com/dyfisgod/p/8558726.html
Copyright © 2020-2023  润新知