WPF PasswordBox:如何警告用户大写锁定已启用?
有谁知道如何实现标准气泡消息,每当启用大写锁定并且密码控件获得焦点时都会警告用户? 这是内置于 .NET 框架中的,还是我需要编写自己的类来执行此操作?
Does anyone know how to implement the standard bubble message that warns users whenever Caps Lock is enabled and a password control has focus? Is this built into the .NET framework, or do I need to write my own class to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个老问题,已经回答了,但我遇到了同样的问题,我首先从
Keyboard.IsKeyToggled(Key.CapsLock)
开始,但如果 Caps 返回false
锁定是在应用程序运行之前设置的。 所以我找到了另一个完美的解决方案。绝对出色且简单(它位于 mscorlib dll 中,因此您也不必担心不需要的依赖项)
This is an old question, and already answered, but I came across this same problem and I first started with
Keyboard.IsKeyToggled(Key.CapsLock)
but that returnedfalse
if Caps Lock was set prior to the application running. So I found another solution that works perfectly.Absolutely brilliant and simple (it's in the mscorlib dll so you don't have to worry about unneeded dependencies either)
您可以将处理程序函数添加到 PasswordChanged< /a> 事件处理程序并测试该函数中 CapsLock 键的值。 如果发现已打开,您可以从那里弹出一条消息。
You could add a handler function to the PasswordChanged event handler and test for the value of the CapsLock key in that function. If found to be on, you could pop-up a message from there.
如果您使用 MaskedTextBox 并指定密码字符,.NET 框架将自动为您执行此操作
If you use a MaskedTextBox and specify a passwordChar the .NET framework will automatically do this for you