如何让 TextBox 使用密码字符而不是 wpf 中的密码框?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11735133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make TextBox to use password characters instead of using passwordbox in wpf?
提问by ASHOK A
Is there any change to make TextBox to use password characters instead of using passwordbox in wpf ?
是否有任何更改可以使 TextBox 使用密码字符而不是在 wpf 中使用密码框?
<PasswordBox Height="42" Width="200" Margin="22,28,28,0"
Name="passwordBox1" VerticalAlignment="Top"
Background="LightBlue" Foreground="DarkBlue"
MaxLength="25" PasswordChar="*"
/>
with above code i can get the result what i need but I have to achieve the same result using textbox instead of passwordbox .what should i do for that.
使用上面的代码,我可以得到我需要的结果,但我必须使用文本框而不是密码框来实现相同的结果。我应该怎么做。
回答by logicnp
The TextBox does not have have a "password mode". PasswordBox is the only way to go.
TextBox 没有“密码模式”。PasswordBox 是唯一的出路。
回答by Norbert
You can change a textbox as a password box, by changing the property of textbox.
您可以通过更改文本框的属性将文本框更改为密码框。
First you create a textbox and press F4. property will open. on that look for 'passwordchar' and change that into '*'. and change whatever you want,like maximum length.
首先创建一个文本框并按 F4。物业将开放。在那寻找'passwordchar'并将其更改为'*'。并更改您想要的任何内容,例如最大长度。
I think it will help to you..
我想它会对你有帮助..

