WPF问题 现在要以一个TextBlock做一个密码框的水印,现如今要判断密码框中是否存在密码,若有密码我让TextBlock显示,若是没有则不显示,但是我要怎么判断密码框是不是获取了焦点,以为TextBlock显示与否的逻辑是要在密码框没有取得失去焦点时写,怎么解决? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你参考,用WPF就别用那么土的方式去做事 <TextBox Margin="5,5,5,5" Width="500" Height="25" HorizontalAlignment="Left" HorizontalContentAlignment="Right"> <TextBox.Resources> <VisualBrush x:Key="helpBrush" TileMode="Tile" Stretch="Fill" AlignmentX="Right" AlignmentY="Center"> <VisualBrush.Visual> <Grid Background="{DynamicResource BasicTextBox_Background}" Width="500" Height="25"> <TextBlock Foreground="Gray" Opacity="0.5" Margin="0,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center" > <Italic>我是水印哦 </Italic> <Run>(*^_^*)</Run> </TextBlock> </Grid> </VisualBrush.Visual> </VisualBrush> <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.Resources> </TextBox> 你可以试试在密码框的onfocused事件中处理(onfocused是获取焦点事件) 这位大大PasswordBox里面是没有Text属性的。 我说了,给你参考,只是告诉你解决这个问题的思想,在WPF中用事件去控制UI的方式弱爆了。 嗯嗯,我现在是想用触发器去做这个了.不会Blend有点蛋疼.这位大大Blend的使用要怎么学比较好呢? 其实网上还是有很多怎么给Password添加水印的方法的. 如何在pictureBox中获取画出来的对象! 继承第三方控件后看不到设计界面,紧急求助! 声卡采集系统怎么做呀? 如何更新dataset到数据库 A类引用B类,在B类里怎么又怎么调用A类的控件属性 如何检测方法是否已经定义? 对取图的疑惑,在线等! 泛型继承,无法排序 关于登录后的窗口问题 求一段使用C#实现的添加链接的正则表达式 VS2010中rdlc报表如何添加页码? listView问题
<TextBox Margin="5,5,5,5" Width="500" Height="25"
HorizontalAlignment="Left" HorizontalContentAlignment="Right">
<TextBox.Resources>
<VisualBrush x:Key="helpBrush" TileMode="Tile"
Stretch="Fill"
AlignmentX="Right" AlignmentY="Center">
<VisualBrush.Visual>
<Grid Background="{DynamicResource BasicTextBox_Background}"
Width="500" Height="25">
<TextBlock Foreground="Gray" Opacity="0.5" Margin="0,0,5,0"
HorizontalAlignment="Right" VerticalAlignment="Center" >
<Italic>我是水印哦 </Italic>
<Run>(*^_^*)</Run>
</TextBlock>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
<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.Resources>
</TextBox>
这位大大PasswordBox里面是没有Text属性的。
嗯嗯,我现在是想用触发器去做这个了.不会Blend有点蛋疼.这位大大Blend的使用要怎么学比较好呢?
其实网上还是有很多怎么给Password添加水印的方法的.