

Private void OnDescriptionPaste(object sender, DataObjectPastingEventArgs e)
TELERIK WPF GET PLAIN TEXT FROM PASSWORDBOX HOW TO
This might not be the exact answer your looking for but here is how to handle pasted text (this also works if user pasted using a the context menu): InitializeComponent() ĭataObject.AddPastingHandler(DescriptionTextBox, OnDescriptionPaste) See the other answer for details on how to bind the Text property when you are using the TextBoxRestriction class so it won't trigger the restriction when you don't want it to. For example you could change TextBoxRestriction to call your own code to validate using an attached property that takes a delegate or an object containing an event. There are many ways to structure your code depending on what you want.

This is just an idea of how it could be handled. It would be the same except that the inner loop would check inserts, not deletes. This same technique can be generalized for use with any restrictions you want to place on your TextBox control.įor example, in your case you might implemnt a RestrictValidChars attached property similarly to the RestrictDeleteTo property in that code.

In this answer I show how to implement a TextBoxRestriction class for the particular scenario being asked about. A much better solution is to monitor TextBox.TextChanged and reject changes that you don't like. Trying to reliably intercept all of these is an exercise in futility. Accessiblity: Voice commands, Braille keyboards, etc.RaiseEvent: Code raises Paste, Cut, Undo, Redo commands.Click: Space bar pressed when Paste, Cut, Undo buttons have local focus.MouseDown: Paste button, Cut button, Undo button.Command Gestures: Ctrl-X, Ctrl-Y, Ctrl-V, Ctrl-X.The trouble with trying to intercept and trap all the individual events that might cause a TextBox.Text property to change is that there are many such events:
