Answered by:
Is there a way to serialize my objects to XAML in Windows Store applications?

Question
-
Is there a way to serialize my objects to XAML in Windows Store applications? I've searched wherever I could, and found nothing... I need something like the methods inside System.Xaml.XamlServices.Monday, December 23, 2013 10:48 PM
Answers
-
You'll have to implement it yourself. You'll need to iterate the visual tree to find the controls and then can serialize them with XML classes. The big trick will be determining which properties are essential to set and which can be left for default.
--Rob
- Marked as answer by Anne Jing Wednesday, January 1, 2014 5:28 AM
- Unmarked as answer by Anne Jing Wednesday, January 1, 2014 5:28 AM
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Saturday, January 11, 2014 12:40 AM
Tuesday, December 31, 2013 12:52 AMModerator
All replies
-
Hi Shayan,
If you search for "serialize" in the search box in the top right of the Windows Store apps dev center you'll get hits on .Net serialization classes you can use in your Windows Store app. You can also use the Object Browser inside Visual Studio to find such classes.
Likewise if you follow the "samples" link in the dev center and search for "serialize" there are a number of samples available.
--Rob
Tuesday, December 24, 2013 12:29 AMModerator -
I know how to serialize an object, I want to serialize to and deserialize from XAML.Wednesday, December 25, 2013 11:38 AM
-
What do you mean by serialize to and deserialize from XAML? It would help if you could provide more clear examples of what you are trying to do.
There is a XamlReader class which can load a Xaml fragment into an object tree. There is no analogous writer, but you can serialize and deserialize your data objects to XML and rebuild a Xaml tree based on that.
--Rob
Friday, December 27, 2013 12:17 AMModerator -
There is a XamlReader class which can load a Xaml fragment into an object tree. There is no analogous writer, but you can serialize and deserialize your data objects to XML and rebuild a Xaml tree based on that.
Friday, December 27, 2013 11:52 AM -
You'll have to implement it yourself. You'll need to iterate the visual tree to find the controls and then can serialize them with XML classes. The big trick will be determining which properties are essential to set and which can be left for default.
--Rob
- Marked as answer by Anne Jing Wednesday, January 1, 2014 5:28 AM
- Unmarked as answer by Anne Jing Wednesday, January 1, 2014 5:28 AM
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Saturday, January 11, 2014 12:40 AM
Tuesday, December 31, 2013 12:52 AMModerator