如何在PasswordBox中设置插入符号位置 [英] How to set the caret position in PasswordBox

查看:91
本文介绍了如何在PasswordBox中设置插入符号位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我需要一些有关如何在passwordBox中设置插入符号位置的帮助.我可以在textBox中进行操作,但找不到有关passwordBox属性的任何信息..

例如
我正在为textBox和passwordBox使用虚拟键盘.在textBox中一切都很好,但是当使用passwordBox时我无法像Select(),SelectionStart,SelectedText这样..
现在我需要如果将插入符号位置保持在中间,则字符应该在该插入符号位置获得类型,如果我删除插入符号位置的字符,则应该删除特定的插入符号位置..它不应该像(textBox.text .length-1)..
有关此问题的任何其他疑问,请让我知道.

在此先感谢,
Ahilan.

Hi All,
I need some help about how to set the caret position in passwordBox..I could able to do in textBox but cant find any information about passwordBox properties..

For example,
I''m using virtual keyboard for the textBox and passwordBox..Everything is fine in textBox but when using passwordBox I couldn''t get like Select(),SelectionStart,SelectedText like this..
Now I need if I keep the caret position at the middle, character should get type at that caret position,,if I delete the character at the caret position that particular caret position should be deleted..It should not be like (textBox.text.length - 1)..
Any further queries about this question Let me know..

Thanks in Advance,
Ahilan.

推荐答案

是的,此类属性未公开.这意味着该控件并不是真正为执行此类操作而设计的.该库的作者设想此控件的功能要窄得多.

不用担心-使用常规WPF TextBox.我敢肯定,您可以使用一些简单的技巧轻松隐藏键入的字符.一种方法是:处理PreviewTextInput事件,以用密码字符(如"*")替换字符,同时记住从同一事件处理程序读取的真实"输入并将其保留在内存中(不可见).

—SA
Yes, such properties are not exposed. It means this control is not really designed to do such things. Authors of the library envisioned much narrower functionality for this control.

Not to worry — use regular WPF TextBox. I''m sure you could easily hide the typed characters using some minimalistic trick. One approach is: handle PreviewTextInput event to replace the characters with a password character (like ''*'') while remembering "real" input read from the same event handler and keeping it in memory, invisible.

—SA


这篇关于如何在PasswordBox中设置插入符号位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆