Is it possible to mark the PasswordBox.SecurePassword
as ReadOnly
?
Consider this simple code:
XAML:
<StackPanel>
<PasswordBox Name="pBox" MinWidth="100" />
<Button Content="OK" Click="Button_Click" Width="50" />
</StackPanel>
C#:
private void Button_Click(object sender, RoutedEventArgs e)
{
pBox.SecurePassword.MakeReadOnly();
Console.WriteLine(pBox.SecurePassword.IsReadOnly());
}
It will output False
. Why?
EDIT: Just to make sure, I tried this and it output "True" as expected.
private void Button_Click(object sender, RoutedEventArgs e)
{
SecureString s = new SecureString();
s.MakeReadOnly();
Console.WriteLine(s.IsReadOnly());
}