1
我可以「導入」圖像(拾取文件)並將其包裝在邊框中的inlineUIContainer中。
- 但是,當我保存文檔時,圖像消失(非常短的文件)。RichTextBox中的圖像(FlowDocument)
或者我可以從剪貼板粘貼(無邊框封裝)。
- 那麼它得到保存爲文件 - 但我有在顯示無法控制......
什麼是在FlowDocument的導入圖像(從文件),並保持實際的位圖
的正確方法,所以它可以與RichText的其餘部分一起保存?
編輯:
我的問題似乎是,該圖像表示(在XAML)與URI
- 而不是實際的位圖 - 所以如何導入/正確地嵌入了嗎?
這是我的導入代碼:
string fileName = openFileDialog.FileName;
BitmapImage bitmap = new BitmapImage(new Uri(fileName, UriKind.Absolute));
Image image = new Image();
image.Source = bitmap;
image.Width = bitmap.Width;
image.Height = bitmap.Height;
Border border = new Border();
border.Background = Brushes.Blue;
border.BorderBrush = Brushes.Red;
border.BorderThickness = new Thickness(10);
border.Margin = new Thickness(10);
border.Padding = new Thickness(10);
border.Child = image;
InlineUIContainer box = new InlineUIContainer(border, rt.CaretPosition);
選中此http://stackoverflow.com/questions/14895745/saving -richtextbox-flowdocument-to-image – Techidiot
感謝Techidiot,但那根本不是。我只想將圖像保存爲「內部」 - 不將圖像導出爲圖像。 – T4NK3R
爲什麼每一件小事都是WPF中黑客和變通辦法的噩夢?!?我現在試圖通過在內部使用剪貼板作弊,但這也非常困難,並且不允許透明(png和gif),所以完全放棄了WPF ... – T4NK3R