WPFTextBox控件显示水印
WPFTextBox控件显示水印效果
<TextBox x:Name="TbxInput" Grid.Row="1" Width="320" Height="25" Margin="0" VerticalAlignment="Center" VerticalContentAlignment="Center" Text="{Binding SelectInfo,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
<TextBox.Resources>
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.3" Stretch="None" AlignmentX="Left">
<VisualBrush.Visual>
<TextBlock FontStyle="Normal" Text="工艺编码、工艺名称" />
</VisualBrush.Visual>
</VisualBrush>
</TextBox.Resources>
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource HelpBrush}"/>
</Trigger>
<Trigger Property="Text" Value="">
<Setter Property="Background" Value="{StaticResource HelpBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding CmdSelectProcessItem}" ></KeyBinding>
</TextBox.InputBindings>
</TextBox>

浙公网安备 33010602011771号