加载时:
private void Window_Loaded(object sender, RoutedEventArgs e) { //控件名称 //事件名称 DataObject.AddPastingHandler(textBox2, TextBoxPlus_PastingEvent); }
事件:
private void TextBoxPlus_PastingEvent(object sender, DataObjectPastingEventArgs e) { if (e.DataObject.GetDataPresent(typeof(String))) { String pastingText = (String)e.DataObject.GetData(typeof(String)); e.CancelCommand(); } }