您可以使用CommandManager.PreviewExecuted
路由事件.这是在调用RoutedCommand上的Execute方法时引发的.
在构造函数中:
CommandManager.AddPreviewExecutedHandler(textBox, onPreviewExecuted);
职能:
private void onPreviewExecuted(object sender, ExecutedRoutedEventArgs e)
{
// Check if the executed command is a copy command
if (e.Command == ApplicationCommands.Copy)
{
// Custom processing here
// ...
// Mark the event as handled to prevent the default copy operation
e.Handled = true;
}
}