C#获取到系统剪切板中复制的图片资源,展示到程序中
IDataObject iData = Clipboard.GetDataObject(); private void BasePage_PreviewKeyDown(object sender, KeyEventArgs e) { //Ctrl+V 粘贴 if ((e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl)) && e.KeyboardDevice.IsKeyDown(Key.V)) { if (iData.GetDataPresent(DataFormats.FileDrop)) {
var files = Clipboard.GetFileDropList(); if (files.Count == 0) { return; } if (files[0] != null) { image_ocr.Source = new BitmapImage(new Uri(files[0])); } } } } }