What’s the rationale (if any) of using XamlWriter.Save() to serialize a domain object?
Please describe realistic scenarios.
Thanks.
What’s the rationale (if any) of using XamlWriter.Save() to serialize a domain object? Please
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s little reason to serialize a domain object into XAML unless you’re going to directly modify the serialized XAML. But there are plenty of circumstances in which you might do that.
For instance, suppose you have a view model object that you want to use while designing a UI in Expression Blend. Usually, what you’ll do is write code that generates a test instance of the object and then reference that code in the Blend project. But you can also serialize the object to XAML and add the XAML file to the Blend project.
This can be pretty useful. Once you’ve done this, you can tweak the property values of your test object inside of Blend by editing its XAML representation instead of modifying the code that creates it. Of course you can accomplish more or less the same thing by using regular XML serialization – modifying the serialized XML file that your test object’s constructor uses is almost exactly the same thing as modifying serialized XAML. The difference is that you can embed the XAML representation directly in other XAML files.
Another benefit that you get is that if XAML is your serialization format you can use markup extensions and value converters. Again, this is only going to be useful if you’re modifying the serialized XAML, like in the scenario I just described.