Password TextBox Char

in the text field in Windows Forms, the PasswordChar property is used. In WPF, there is additional control for this: PasswordBox. This is not a problem, but my application only works on a touch screen device. Unfortunately, the password window does not support the on-screen keyboard. I was wondering if there is a way to add a char password to a standard text field.

+6
source share
4 answers

This answer may provide you with what you need.

+4
source

I circumvented this issue by creating two properties for the password contents and binding them both to the same model value. One of them (a visible user interface element) is associated with a password. The Get on function of this property, of course, returns an array of characters to display. Functions that should use password text can use the PlainPassword property.

Adding "UpdateSourceTrigger = PropertyChanged" to the Binding for the text field causes characters to appear in the text field as you type them.

public string Password { set { Model.Password = value; OnPropertyChanged("Password"); } get { return new String('●', Model.Password.Length); } } public string PlainPassword { set { Model.Password = value; OnPropertyChanged("Password"); } get { return Model.Password; } } 
+2
source

I believe that the only way to achieve this is to create your own control based on the text field. Then just bind the actual text property to the property that returns your password, not the actual password. Then you can output the password as a dependency property (although I heard that it is rather unsafe, therefore it is not a dependency property in the password field) or just a regular property and access to it by transferring the entire text field object.

+1
source

Hello!

im new here, but maybe i can help u. I find this -> can work with WPF and password

 private void delete_Click(object sender, RoutedEventArgs e) { if (pass_passbox.IsFocused == true) { pass_passbox.Password= ""; } } 

ofc u do this pass_passbox.Text if its a text box, but when changing the password of the WPF code u you need to write pass_passbox.Password and you can make changes from the on-screen keyboard.

not fully tested, but u can reset this way

and you can do this:

 string Query = "Select * from [employeeinfo] where username='" + this.txt_user_name.Text + "' and password='" + this.pass_passbox.Password + "' "; 

u can see this.pass_passbox.Password the same in the text box this.pass_passbox.Text

-1
source

Source: https://habr.com/ru/post/913944/


All Articles