Поделиться через


PasswordBox.PasswordChanged Event

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Occurs when the value of the Password property changes.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Event PasswordChanged As RoutedEventHandler
public event RoutedEventHandler PasswordChanged
<PasswordBox PasswordChanged="eventhandler"/>

Remarks

The PasswordChanged event is raised even if the Password property is reset to the same text.

The PasswordChanged event cannot be bubbled or cancelled.

Examples

The following code snippets display a password box and a read-only text box. As you type a password in the password box, the text is displayed in the read-only text box. This example is part of a larger example available in the PasswordBox class overview.

<TextBlock Text="Type password here" Margin="20,10,0,0"/>
<PasswordBox x:Name="MyPWBox1" Margin="20,10,0,0" PasswordChanged="MyPWBox1_PasswordChanged" MaxLength="8" Height="35" Width="200" HorizontalAlignment="Left" />
<TextBlock Text="Password" Margin="20,10,0,0"/>
<TextBox x:Name="ReadOnlyTB" Margin="20,10,0,0" HorizontalAlignment="Left" IsReadOnly="True" Height="35" Width="200" />
'Displaying the password typed in MyPWBox1 in ReadOnlyTB
Private Sub MyPWBox1_PasswordChanged(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ReadOnlyTB.Text = MyPWBox1.Password
End Sub
private void MyPWBox1_PasswordChanged(object sender, RoutedEventArgs e)
{
    ReadOnlyTB.Text = MyPWBox1.Password;
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.