WPF中的密码框

WPF中的密码框

XAML文件

<PasswordBox Name="PasswordBox" Margin="5" Padding="5" PreviewKeyDown="Txtpassword_PreviewKeyUp"/>

 

后台代码:

IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(this.PasswordBox.SecurePassword);
            string password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);

 

posted @ 2023-05-31 14:10  牛腩  阅读(106)  评论(0编辑  收藏  举报