PasswordBox and MVVM

后端 未结 5 1560
再見小時候
再見小時候 2021-02-02 13:35

We have the following scenario:

  1. MVVM userinterface where a user can place his password (actually a PasswordBox)
  2. Server that shall do some wor
5条回答
  •  有刺的猬
    2021-02-02 14:09

    depending on your understanding of mvvm (in my way code behind is allowed in some cases)

    so i create a PasswordBox and also a named TextBlock

    Xaml

    
    
    

    codebehind

        private void pwBoxUser_PasswordChanged(object sender, RoutedEventArgs e)
        {
            var pBox =sender as PasswordBox;
            string blank=pBox.Password;
    
            //to crypt my blank Password
            var sMD5 = myMD5.toMD5(blank); //implement your crypt logic here
            blank ="";
    
            MD5pw.Text = sMD5;
        }
    

    like you can see your password is save and you can easy bind to it

提交回复
热议问题