InkCanvas Clipboard RRS feed

  • Question

  • Hi,

    I would like to know how to copy ink canvas element to clipboard?

    Right now what my application can do is copy element to ink canvas itself.

    Thanks in advance.:)

    Thursday, September 23, 2010 11:15 AM


  • Hi Alhyzz,

    You cannot copy an InkCanvas to clipboard directly because it is not supported by clipboard.

    You can use XamlWriter.Save method to save the InkCanvas as a string, then you can use Clipboard.SetData method to copy this string to clipboard.

    Please see the following sample. It copies an InkCanvas to the Clipboard and recreate an InkCanvas from the Clipboard.

                InkCanvas inkCanvas = new InkCanvas();


                //Copy to clipboard

                string savedInkCanvas = XamlWriter.Save(inkCanvas);

                Clipboard.SetData(DataFormats.StringFormat, savedInkCanvas);


                //Copy from clipboard

                string loadedInkCanvas = Clipboard.GetData(DataFormats.StringFormat) as string;

                StringReader stringReader = new StringReader(loadedInkCanvas);

                XmlReader xmlReader = XmlReader.Create(stringReader);

                InkCanvas readerLoadInkCanvas = (InkCanvas)XamlReader.Load(xmlReader);

    For more information about Clipboard.SetData method, please refer to http://msdn.microsoft.com/en-us/library/system.windows.clipboard.setdata.aspx.

    Hope this helps.

    Best regards,



    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Min Zhu Thursday, September 30, 2010 1:29 AM
    Monday, September 27, 2010 8:48 AM