How to: Handle MouseUp and MouseDown Events for a PasswordBox
PasswordBox has built-in handling for the bubbling MouseUp and events. Consequently, custom event handlers that listen for MouseUp or MouseDown events from a PasswordBox will never be called. If you need to respond to these events, listen for the tunneling PreviewMouseUp and PreviewMouseDown events instead.
The following Extensible Application Markup Language (XAML) example shows how to use the PreviewMouseUp and PreviewMouseDown attributes to specify the handler delegates for these events.
The following example shows how to add event listeners programmatically.
PasswordBox pwBox = new PasswordBox(); pwBox.PreviewMouseUp += MouseUpHandler; pwBox.PreviewMouseDown += MouseDownHandler;
The following example shows empty event handler methods that correspond to the delegates specified in the previous examples.