开发者

How to serialise control + code in WPF?

I have a canvas which contains several userControls, which in it's turn contains other objects. I want to serialise the canvas and preserve all databindings and whole visual tree (not all objects can be described in xaml).

I thought creating a custom control which extends canvas and adds ability to serialise will solve thi开发者_JS百科s problem.

So the question is: is it a right approach? If not, what is the best way to do it?


You should understand that your UI is just a way to show the state of your presenter. If you`re using Presentation Mode or MVVM , you can just serialize your presenter. It will solve all your problems


I found one work around. That is to put the details of non-seriazable Objects into dictionary or other data structure and serialise it and later retrieve it there when de-serialising the object.

However this doesn't sound very right to me :/ Also had I thought to use both XamlWriter and serialisation to serialise controls, but again I don't think it is the best approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜