Make WPF textbox as cut, copy and paste restricted

Cut, Copy and Paste are the common commands used any application,

<TextBox CommandManager.PreviewExecuted="textBox_PreviewExecuted"/>

in above textbox code we can restrict these commands in PrviewExecuted event of CommandManager Class

and in code behind add below code and your job is done

private void textBox_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
if (e.Command == ApplicationCommands.Copy ||
e.Command == ApplicationCommands.Cut  ||
e.Command == ApplicationCommands.Paste)
e.Handled = true;

If you have any query please leave a comment.


2 Responses to “Make WPF textbox as cut, copy and paste restricted”

  1. Amin Says:

    Many times i have search …. but here i found the perfect and easy solution. Thanks a lot…

  2. Henrique Clausing Cunha Says:

    Thanks so much!! I have made it with override for PreviewKeyDown … but its context menu have broken all my job… this will get my job done!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: