Don't think that is possible with PasswordBox... just a thought, but you might accomplish the same result using a hidden TextBox and when the user clicks the CheckBox, you just hide the PasswordBox and show the TextBox; if he clicks again, you switch their Visibility state again, and so on...
Edit
And here it is how!
Just add a page, change the ContentPanel to a StackPanel and add this XAML code:
<PasswordBox x:Name="MyPasswordBox" Password="{Binding Text, Mode=TwoWay, ElementName=MyTextBox}"/>
<TextBox x:Name="MyTextBox" Text="{Binding Password, Mode=TwoWay, ElementName=MyPasswordBox}" Visibility="Collapsed" />
<CheckBox x:Name="ShowPasswordCharsCheckBox" Content="Show password" Checked="ShowPasswordCharsCheckBox_Checked" Unchecked="ShowPasswordCharsCheckBox_Unchecked" />
Next, on the page code, add the following:
private void ShowPasswordCharsCheckBox_Checked(object sender, RoutedEventArgs e)
{
MyPasswordBox.Visibility = System.Windows.Visibility.Collapsed;
MyTextBox.Visibility = System.Windows.Visibility.Visible;
MyTextBox.Focus();
}
private void ShowPasswordCharsCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
MyPasswordBox.Visibility = System.Windows.Visibility.Visible;
MyTextBox.Visibility = System.Windows.Visibility.Collapsed;
MyPasswordBox.Focus();
}
This works fine, but with a few more work, you can do this fully MVVM'ed!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…