Silverlight 密码框显示“请在此处输入密码”里面
如何在 Silverlight 4 中设置 PasswordBox
,以便当它为空时,在密码框中内部显示文本“请在此处输入密码”?
我希望文本显示在密码框中,而光标在行的开头闪烁。当用户开始输入时,文本应消失并显示默认密码字符。 当用户完全删除密码时,文本应该再次显示。
这可以用纯 XAML 实现吗?
如果没有,我也希望有一个带有一些事件处理程序和隐藏代码的解决方案。提前致谢!
How can I setup a PasswordBox
in Silverlight 4 so that when it's empty it shows the text "Please enter password here" inside the PasswordBox?
I want the text to show up in the PasswordBox, while the cursor is blinking on the very beginning of the line. When the user starts typing, the text should disappear and the default password characters should be shown.
When the user erases the password completely, the text should be shown again.
Is this possible with pure XAML?
If not, I'd also appreciate a solution with some event handlers and code behind. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在文本框和密码框之间切换,例如在 GotFocus、LostFocus 上
Try to switch between textbox and passwordbox, for example on GotFocus, LostFocus
我现在实施了以下解决方案。它不是纯XAML,但我认为还可以。
在 XAML 中,我放置了一个
PasswordBox
,后跟一个TextBlock
,其中包含与密码框重叠的“输入您的密码”文本。在PasswordBox 的事件处理程序中,TextBlock 将变得不可见。(将以上内容放在一个
Grid
单元格中。)在后面的代码中,添加事件处理程序:
I now implemented the following solution. It's not pure XAML, but I think it's ok.
In XAML I put a
PasswordBox
, followed by aTextBlock
with the "Enter your password" text which overlaps the PasswordBox. In the event handler of the PasswordBox the TextBlock will be made invisible.(Put the above together in one
Grid
cell.)In the code behind, add the event handler: