in my application i have this code:
<Grid Name="BaseGrid">
<Grid.Resources>
<XmlDataProvider x:Name="ScenesXmlName" x:Key="ScenesXml" XPath="person" Source="myXml.xml"/>
</Grid.Resources>
<ComboBox Grid.Column="0" Name="ScenariCombo" IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource ScenesXml}}" DisplayMemberPath="@name" />
</Grid>
Suppose my xml is:
<person name="John">
<address>Some adress here</address>
<work>Some work</work>
</person>
I’m planning to update several user controls when the selection changes.
the problem is that ComboBox.SelectedItem is not a custom object but an XmlNode as the Combobox is binded to an XmlDataSource.
How would you access an inner node ie: address of the SelectedItem item?
I built a little example for you. It works but i am sure you can do better than that.
my Xaml file:
my Xml2AddressConverter class
Have a look to this it shows a little bit how to query data from xml stuff using LINQ to XML.