Save and load Ink Canvas StrokeCollection to/from stream

前端 未结 1 2016
梦如初夏
梦如初夏 2021-01-17 01:18

I\'m trying to serialize an ink canvas in WPF. So I\'m using StrokeCollection.Save to save the strokes to a MemoryStream. But when I try to load th

相关标签:
1条回答
  • 2021-01-17 01:45

    Did you check the Position of the your stream?

    I think that after saving the stroke into it it will point to the end of it.
    Try to reset the position to the first character, like this:

    using (MemoryStream ms = new MemoryStream())
    {
        inkcanvas.Strokes.Save(ms);
        ms.Position = 0;
        inkcanvas.Strokes = new System.Windows.Ink.StrokeCollection(ms);
    }
    
    0 讨论(0)
提交回复
热议问题