texbox 禁用copy paster cut

<TextBox CommandManager.PreviewExecuted="textBox_PreviewExecuted"
         ContextMenu="{x:Null}" />

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;
     }
}
posted @ 2018-04-20 10:16  马肯尼煤牙巴骨  阅读(212)  评论(0编辑  收藏  举报