How to set mode Password for TextBox control?  
Author Message
hoangha





PostPosted: Windows Presentation Foundation (WPF), How to set mode Password for TextBox control? Top

I want to set TextBox to password mode (with * for each character). I can not find out how to implement this feature. Please help me...

Thanks.



Visual Studio 20086  
 
 
IanG





PostPosted: Windows Presentation Foundation (WPF), How to set mode Password for TextBox control? Top

The TextBox doesn't have a password mode. Instead, there's a special control for this: PasswordBox.

I think the main reason for this is that TextBox supports a bunch of features that you almost certainly don't want in a password box, like multiline text, typography, text decorations.


 
 
lester - MSFT





PostPosted: Windows Presentation Foundation (WPF), How to set mode Password for TextBox control? Top

Use PasswordBox control and set PasswordChar as '*'
 
 
hoangha





PostPosted: Windows Presentation Foundation (WPF), How to set mode Password for TextBox control? Top

Thanks guy,

It works fine... excellent!


 
 
GC





PostPosted: Windows Presentation Foundation (WPF), How to set mode Password for TextBox control? Top

Is there any way to monitor the caret index of a passwordbox like you can in a textbox

 
 
LesterLobo - MSFT





PostPosted: Windows Presentation Foundation (WPF), How to set mode Password for TextBox control? Top

the passwordbox doesnt support it....

You are really looking for a masked textbox which isnt supported in the current version. .. an alternative is to use the Winforms MaskedTextBox.