public Window1()
{ InitializeComponent();
// "tb" is a TextBox
DataObject.AddPastingHandler(tb, new DataObjectPastingEventHandler(OnPaste));
} private void OnPaste( object sender, DataObjectPastingEventArgs e)
{ var isText = e.SourceDataObject.GetDataPresent(System.Windows.DataFormats.Text, true );
if (!isText) return ;
var text = e.SourceDataObject.GetData(DataFormats.Text) as string ;
} |
本文转自lpxxn博客园博客,原文链接:http://www.cnblogs.com/li-peng/archive/2013/01/05/2846368.html,如需转载请自行联系原作者