问题
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