• 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>
  • 相关阅读:
    rest framework 之前
    python之psutil
    可持久化并查集总结
    复数学习
    主席树总结
    点分治题单(来自XZY)
    Tarjan&2-SAT 总结
    AC自动机题单
    网络流题目详讲+题单(入门版)(持续更新中......)
    网络流题目详讲+题单(提高版)(持续更新中......)
  • 原文地址:https://www.cnblogs.com/dyfisgod/p/8558726.html
Copyright © 2020-2023  润新知