私は WPF ベースのアプリケーションを書いていますが、それに問題があります。私は何週間も答えを探しましたが、まだ解決策を見つけることができませんでした. 問題は、ヒント付きの背景テキストを表示できないことです。私は独自のスタイルを使用して、トリガーを介してテキストを表示しようとしています。私が作成したコードサンプルは次のとおりです。
<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>
どこに問題があるのか教えてください。ああ、もう 1 つの質問: 同様の方法を使用して passwordbox の背景テキストを出力することは可能ですか? ありがとうございました!