WPF中如何设置PasswordBox控件显示原文?
获取passwordBoxPassword中密码的代码如下:// 使用一个IntPtr类型值来存储加密字符串的起始点IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(this.passwordBoxPassword.SecurePassword);// 使用.NET内部算法把IntPtr指向处的字符集合转换成字符串string password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);// 顺便校验一下if (string.IsNullOrEmpty(password) || password!="123456"){MessageBox.Show("请输入密码", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk);return;}注意:如果程序中的PasswordBox比较多,建议提前引用System.Runtime.InteropServices名称空间。
box网盘密码忘了怎么办?
代码太长,这里没法贴全地址:https://coding.net/u/foolrabbit/p/SmallProject/git/tree/master/SmallProject/DataGridSamplexmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:DataGridSample"Title="MainWindow" Height="350" Width="525">ItemsSource="{Binding DataSource}"CurrentColumn="{Binding CurrColName,Converter={StaticResource columnConverter},Mode=OneWayToSource}">Text="{Binding ColValue}"/>
转载请注明出处51数据库 » wpf passwordbox用法