I'm looking for a method to serialize/save a visual tree from an object. It should be possible to reload/show this tree in other applications even when not all (custom)controls are available. The result should be proportinal scalable (vectorgrafic) and controlindependet. The best solution I found for my problem so far is XamlWriter.Save() but this generates xaml with all dependencies. Xps are nearly that's what I'm looking for but is it possible to show them without a xpsviewer?
Asked
Active
Viewed 209 times
0
-
3You don't "serialize the UI" because [UI is not Data](http://stackoverflow.com/a/14382137/643085). Try serializing your data instead. – Federico Berasategui Dec 05 '13 at 14:11
-
I will store the visual information (like vector-graphics). App A will have a huge set of custom controls and App B should know nothing about the controls, so I have to store the visual information (instead of 0,0 Button -> I will store all rectangles, gradient brushes borders). What I'm looking for is a concept to iterate through the visual tree from a control. – wischi Dec 06 '13 at 22:11
1 Answers
0
As @HighScore said, instead of thinking of, how to serialize UI object, think of how to serialize your data.
Design data model and serialize it into whatever format you like. I would prefer JSON as it is lightweight, simple and supported everywhere.
Then, just use the data where you need it to re-create tree for example.

Andrei
- 42,814
- 35
- 154
- 218
-
I won't serialize Ui, I will serialize visuals (rectangles, circles, text, colored boxes, etc. With the "App A" I will create a designer do design (for example) an image/drawing in xaml (even with some special custom controls) then store the "vector-image" in fixed ratio an then present this in "App B" without knowing the special custom controls. The technique should be similar to xps (only basic types allowed: polygones, lines, glyphs) and any visual representation of the current state of the custom control should be serialized. When I only store the data so B must know those special controls – wischi Dec 06 '13 at 22:06