How can I make a WPF textbox cut, copy and paste restricted?
Cut, Copy, and Paste are the common commands used any application.
<TextBox CommandManager.PreviewExecuted="textBox_PreviewExecuted"
ContextMenu="{x:Null}" />
In the above textbox code we can restrict these commands in PreviewExecuted event of CommandManager Class.
In the code behind add the code below 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;
}
}