views:

253

answers:

1

I have a XElement that has the following structure

<document num="1">
 <pages>
   <page />
   <page />
 </pages>
 </document/>

I have one Listbox named "documents" that is bound to an XElement in the following manner:

ItemsSource="{Binding Path=TheXElement.Elements[document]}"

I want to have a second ListBox named "pages" whose ItemsSource is the pages based on the selected document in the first list box.

ItemsSource="{Binding ElementName=documents,Path=SelectedItem.Element[pages].Elements[page]}" 

Of source ,the above statement does not work. When I try the following ItemsSource="{Binding ElementName=documents,Path=SelectedItem}, the "pages" ListBox does get bound to the correct document, but it gets a binding error "ReferenceConverter cannot convert from System.Xml.Linq.XElement"

I think I'm close, but having issues getting it to work. How can I correctly bind the "pages" ListBox to the SelectedItem of the "documents" ListBox?

Thanks!

A: 

Solved it, using a custom converter

http://msdn.microsoft.com/en-us/library/ms771571.aspx

Taylor