Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Complex Listbox
Message
De
07/11/2009 04:50:24
 
 
À
06/11/2009 17:14:45
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Titre:
Divers
Thread ID:
01433632
Message ID:
01433658
Vues:
39
>I need to display some data from an XML file in a list, but unsure how to exactly handle it.
>
>The data looks like this:
>
><Parents>
>   <Parent Name="Parent1">
>      <Child Title="Child1" Print="Y" Active="Y" PrintPath="C:\Print" LogPath="C:\Log" />
>      <Child Title="Child2" Print="Y" Active="Y" PrintPath="C:\Print" LogPath="C:\Log" />
>   </Parent>
>   <Parent Name="Parent2">
>      <Child Title="Child1" Print="Y" Active="Y" PrintPath="C:\Print" LogPath="C:\Log" />
>   </Parent>
>   <Parent Name="Parent3">
>      <Child Title="Child3" Print="Y" Active="Y" PrintPath="C:\Print" LogPath="C:\Log" />
>   </Parent>
></Parents>
>
>
>Here's how the user wants things displayed. (The ^ indicates an Expander):
>
>^ Parent: Parent1
>    ^ Child: Child1
>        Print: Y   Active: Y           
>        Print Path: C:\Print
>        Log Path: C:\LogPath
>    ^ Child: Child2
>        Print: Y   Active: Y           
>        Print Path: C:\Print
>        Log Path: C:\LogPath
>^ Parent:  Parent2
>
>
>Here are the issues:
>- There can be multiple Parent elements
>- There can be multiple child elements per parent
>- Any parent or child can be deleted
>- Any parent or child can be copied and pasted
>- A new parent or child can be added
>
>I'm thinking of solving it this way:
>- Place everthing in a list box
>- Put parent records in an expander
>- Put a stack panel in the Parent expander
>- Put child records in an expander in the stack panel and use a group box to hold the attributes
>
>Here's what I'm not sure about:
>How do I handle an unknown number of child records per parent?
>How do I deal with insert/delete of child records?
>
>I'll take any suggestions for solving this.

I see you've considered a treeview and that would probably be the simplest - but a ListView approach shouldn't be too difficult either. Make the Parent Collection the ItemsSource to the Listbox and use a DataTemplate for the Children that includes the Expander and another ListBox - binding this one to the CurrentItem.Children of the outer ListBox. Adding/Deleting and Moving should be achievable by just manipulating the underlying objects (I'm assuming that you will derive objects from the XML?)
HTH,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform