Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XamlReader Wall
Message
From
09/03/2009 15:14:17
 
 
To
09/03/2009 13:33:50
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01386282
Message ID:
01386732
Views:
27
Hi,

>I use the xaml writer/reader, but I'm using it with resources, so there is no codebehind to worry about?
>This looked like a fragment of a save and open program. Is that correct? If not what are you trying to do here?

The aim is to encapsulate (either in XML or in a single binary stream ) a Canvas object containing various content (including other nested canvases with, in turn, their own content). AFAICS the XAMLWriter/Reader is meant to reproduce a visual representation but not capsulate the actual hierarchy of objects. If, for example, you have a Usercontrol containing a couple of TextBlocks and add this to a Canvas the XAMLWriter will output something like:
<Canvas>
  <UserControl>
     <TextBlock/>
    <TextBlock/>
  </UserControl>
</Canvas>
If this is passed to the XAMLReader then when it hits the UserControl element the constructor for the control is called resulting in the two TextBlocks being instantiated. The XAMLReader then moves on to the TextBlock element in the XML fragment and creates that as well - thus duplicating the version already created within the UserControl itself. If the TextBlock in question doesn't have a name then it will do this quite happily (if it IS named then you get the Exception previously mentioned) - but you still have two instances in existence. Any code behind references the instance within the UserControl. The one you see is the second one.

I guess I'm just trying to do something that this was never meant for :-{
It's beginning to look as if there is no 'high-level' way of doing this....
Best,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform