开发者

WPF Master -Detail Binding XElement

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 th开发者_JAVA百科e 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!


Solved it, using a custom converter

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜