序列化 Canvas 的内容
Serialize contents of a Canvas
在 WPF 程序中,我可以使用 System.Windows.Markup.XamlWriter
将 WPF Canvas
的内容序列化为文本。但这在 windows store/metro 应用程序中不可用,那么如何序列化 Windows-Store Canvas 的内容?
(我的应用程序类似于绘画应用程序,用户可以在其中使用鼠标进行绘图。'drawings' 与 Line
一样 UIElements
和 Ellipse
添加为children of a Canvas
。我正在寻找一种序列化方法,因为我希望能够 save/restore 这些 UIElements
).
由于 windows 商店应用或 UWP 应用中都没有 System.Windows.Markup.XamlWriter
,我最终使用了 Sharp Serializer。在 WPF 和 Windows RT 中都非常容易使用。
来自此博客 (Choosing the right serialization engine for your Windows Store app) 的其他一些流行的序列化引擎是 XmlSerializer、DataContractSerializer 和 JsonSerializer。
在 WPF 程序中,我可以使用 System.Windows.Markup.XamlWriter
将 WPF Canvas
的内容序列化为文本。但这在 windows store/metro 应用程序中不可用,那么如何序列化 Windows-Store Canvas 的内容?
(我的应用程序类似于绘画应用程序,用户可以在其中使用鼠标进行绘图。'drawings' 与 Line
一样 UIElements
和 Ellipse
添加为children of a Canvas
。我正在寻找一种序列化方法,因为我希望能够 save/restore 这些 UIElements
).
由于 windows 商店应用或 UWP 应用中都没有 System.Windows.Markup.XamlWriter
,我最终使用了 Sharp Serializer。在 WPF 和 Windows RT 中都非常容易使用。
来自此博客 (Choosing the right serialization engine for your Windows Store app) 的其他一些流行的序列化引擎是 XmlSerializer、DataContractSerializer 和 JsonSerializer。