How to bind to a PasswordBox in MVVM

前端 未结 30 2083
执念已碎
执念已碎 2020-11-22 11:50

I have come across a problem with binding to a PasswordBox. It seems it\'s a security risk but I am using the MVVM pattern so I wish to bypass this. I found som

30条回答
  •  自闭症患者
    2020-11-22 12:23

    I have done like:

    XAML:

    
    
    
            
    
    

    C#:

    private void NewPassword_PasswordChanged(object sender, RoutedEventArgs e)
        {
            try
            {
               //change tablenameDataTable: yours! and tablenameViewSource: yours!
               tablenameDataTable.Rows[tablenameViewSource.View.CurrentPosition]["password"] = NewPassword.Password;
            }
            catch
            {
                this.Password.Text = this.NewPassword.Password;
            }
        }
    

    It works for me!

提交回复
热议问题