How to extract XMLElement of selectedItem of ListBox in WPF?

北慕城南 提交于 2019-12-10 11:57:38

问题


Problem Background:

In my WPF application, in one of the window/page contains 3 List Boxes and 1 ComboBox. These 3 ListBoxes are binded with XML dataprovider and there is no issues. I mean when 1st listbox selection changes automatically updates listbox2. In the same way, listbox3 updates as listbox2 changes. These are all worked out in XAMl file alone and there is code-behind except InitializeComponent() and few lines of code for loading this XAML file dynamically using XAMLReader(this is my requirement)

Problem facing Requirement:

OnSelection change event of any of the ListBox, need to populate ComboBox data dynamically( it will fire webservices which is based on above mentioned 3 LisBox selection). For this purpose, in SelectionChange I am trying to get

ListBoxObj.SelectedItem  - Always contains XML tree.(i.e) of type XMLElement

I have tried all possiblities, everywhere I am getting only XML tree.

Anyone have any idea, how to extract ListBox selected Item Text from XMLElement?

Is there a quick way to convert my XmlElement tree into selected text, (or) do I have to invoke a serializer and do it manually?

P.S: For me, XAML file is the only input so I do not know what value is ListBox mapped to. I am not aware whether ListBox is mapped to element / attribute. So first I need to extract mapping information from XAML file and manually parse the XML tree.

Thanks

来源:https://stackoverflow.com/questions/29451808/how-to-extract-xmlelement-of-selecteditem-of-listbox-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!