Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XamlReader Wall
Message
De
09/03/2009 15:14:17
 
 
À
09/03/2009 13:33:50
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Titre:
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01386282
Message ID:
01386732
Vues:
26
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform