WPF中PasswordBox控件怎么显示提示信息?如显示:请输入密码
源码这样写的,但抛个异常
<DockPanel HorizontalAlignment="Center" Height="23" Width="167" Background="White" Margin="115,92,109,67">
<PasswordBox Height="23" HorizontalAlignment="Left" Name="pwdpassword" VerticalAlignment="Top" Width="167">
<!--当文本框为空时,显示提示文字-->
<PasswordBox.Resources>
<VisualBrush x:Key="HelpBrush1" Opacity="0.3" Stretch="None" AlignmentX="Left">
<VisualBrush.Visual>
<TextBlock FontStyle="Italic" Text="请输入密码" />
</VisualBrush.Visual>
</VisualBrush>
</PasswordBox.Resources>
<PasswordBox.Style>
<Style TargetType="PasswordBox">
<Setter Property="Background" Value="White" />
<Style.Triggers>
<!--<Trigger Property="Password" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource HelpBrush1}"/>
</Trigger>-->
<!--<Trigger Property="Password" Value="">
<Setter Property="Background" Value="{StaticResource HelpBrush1}" />
</Trigger>-->
</Style.Triggers>
</Style>
</PasswordBox.Style>
<!--当文本框为空时,显示提示文字-->
</PasswordBox>
</DockPanel>
源码这样写的,但抛个异常
<DockPanel HorizontalAlignment="Center" Height="23" Width="167" Background="White" Margin="115,92,109,67">
<PasswordBox Height="23" HorizontalAlignment="Left" Name="pwdpassword" VerticalAlignment="Top" Width="167">
<!--当文本框为空时,显示提示文字-->
<PasswordBox.Resources>
<VisualBrush x:Key="HelpBrush1" Opacity="0.3" Stretch="None" AlignmentX="Left">
<VisualBrush.Visual>
<TextBlock FontStyle="Italic" Text="请输入密码" />
</VisualBrush.Visual>
</VisualBrush>
</PasswordBox.Resources>
<PasswordBox.Style>
<Style TargetType="PasswordBox">
<Setter Property="Background" Value="White" />
<Style.Triggers>
<!--<Trigger Property="Password" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource HelpBrush1}"/>
</Trigger>-->
<!--<Trigger Property="Password" Value="">
<Setter Property="Background" Value="{StaticResource HelpBrush1}" />
</Trigger>-->
</Style.Triggers>
</Style>
</PasswordBox.Style>
<!--当文本框为空时,显示提示文字-->
</PasswordBox>
</DockPanel>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货