I’m writing an WPF-based application and I’ve got a problem with It. I've searched an answer for weeks, but still couldn't find the solution. The problem is: I can’t show the background text with a tip. I’m using my own written style and trying to show text via triggers. Here’s the code sample I made:
<Style TargetType="{x:Type TextBox}" x:Key="DCTextBox">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="#21346b"/>
<Setter Property="FontFamily" Value="Fonts/#BankGothic Md BT"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border CornerRadius="5" BorderThickness="6" BorderBrush="#21346b" Background="White" >
<ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Resources>
<VisualBrush x:Key="HelpBrush" Opacity="0.4" Stretch="None" AlignmentX="Left" >
<VisualBrush.Visual>
<TextBlock FontStyle="Italic" Text="Type or select from list" Background="Black"/>
</VisualBrush.Visual>
</VisualBrush>
</Style.Resources>
<Style.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Control.Background" Value="{StaticResource HelpBrush}"/>
</Trigger>
<Trigger Property="Text" Value="">
<Setter Property="Control.Background" Value="{StaticResource HelpBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
Please, tell me where could be the problem? Oh, and one more question: is it possible to output the background text in passwordbox using the similar method? Thank you!