Here is a question! I need to perform a zoom on an image, how can I do this? Here, we’ll introduce a way to achieve image zoom by using the mouse in WPF.
Here is the key code.
XAML code: (more…)
Here is a question! I need to perform a zoom on an image, how can I do this? Here, we’ll introduce a way to achieve image zoom by using the mouse in WPF.
Here is the key code.
XAML code: (more…)
There are two common ways to use the control PasswordBOx in WPF.
1. With the Binding, the value of PasswordBox is related with one attribute of the back-end data object.
2. use the “SecurePassword” attribute in PasswordBox.
The first way is annoying and not recommended .The “SecurePassword” was a new attribute in .net 3.5 SP1.So, this article chiefly introduce how to use “SecurePassword “.
Since the data type of “SecurePassword ” is “SecureString”, it is easily writeable and uneasily readable. Especially to be noted, when you call the method “ToString()” in the instance of SecurePassword, the value you always get is “System.Security.SecureString”.
The codes bellowing would show you how to obtain the password in passwordBoxPassword.
view plaincopy to clipboardprint?
/*1.use a value of IntPtr type to store the start-point of the Encrypted string*/
IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(this.passwordBoxPassword.SecurePassword);
/*2. Use .net internal algorithms to convert the characters that the InPtr is pointed to into the string.*/
string password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);
//3. to verify the password.
if (string.IsNullOrEmpty(password) || password!=”123456″)
{
MessageBox.Show(”please input the password”, “”, MessageBoxButton.OK, MessageBoxImage.Asterisk);
return;
}
Powered by WordPress