How to disable copy in password field in Silverlight

Is there a way to prevent the user from entering data in the password field. The requirement is that the user does not have to copy the password from the password field to the password confirmation field. Events with a key event do not seem to help me, since it only fires when the ctrl key is pressed and does not start on ctrl + V.

+3
source share
1 answer

One solution would be to extend the TextBox control to simulate a PasswordBox and override KeyUp / KeyDown events to prevent copy / paste. It seems like someone already wrote this to support East Asian characters:

Allow East Asian characters in PasswordBox

OnKeyDown, :

protected override void OnKeyDown(KeyEventArgs e)
{
    if (e.Key == Key.Ctrl)
        CtrlKeyDown = true;

    if (CtrlKeyDown && (e.Key == Key.C || e.Key == Key.X || e.Key == Key.Z || e.Key == Key.Y || e.Key == Key.V))
        e.Handled = true;
    else
        base.OnKeyDown(e);
}
+1

All Articles