I have a System.Windows.Controls.Image
which is decorated with a couple of adorners. Now I want to copy the adorned image to the clipboard. So far I have this line of code:
System.Windows.Clipboard.SetImage(myImage as BitmapImage);
However, this only copies the image itself; the adorners are not included. Is there a way to include the adorners?
EDIT: Here's some code showing how I adorn myImage
:
MyAdorner myAdorner = new MyAdorner(myImage);
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(myImage);
adornerLayer.Add(myAdorner);
MyAdorner
is a subclass of System.Windows.Documents.Adorner
. I don't think the specifics of the implementation are important.
You will need to render your image and its adorners to a RenderTargetBitmap and then convert that bitmap to an image that can be added to the clipboard.
See the example at the bottom of the page, it should cover everything you need.