OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Add image"; dlg.Filter = "png,jpg|*.png;*.jpg"; if (dlg.ShowDialog() == true) { System.Threading.Thread.Sleep(20); var clipboard = Clipboard.GetDataObject(); BitmapImage bitmapImage = SetImage(dlg.FileName); Clipboard.SetImage(bitmapImage); txt.Paste(); Clipboard.SetDataObject(clipboard); } private BitmapImage SetImage(String filename) { BitmapImage bi = new BitmapImage(); if (System.IO.File.Exists(filename)) { bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.CreateOptions = BitmapCreateOptions.IgnoreImageCache; bi.UriSource = new Uri(filename); bi.EndInit(); } return bi; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)