I'm new to WPF and don't yet have a solid grasp of how things should be done...
I have an xml file that stores config data and I want the data that is in this xml file to be displayed on the gui front end.
I'm currently using an XmlDataProvider that reads in a set of data
The data is roughly like:
<Items>
<Item name="item01">
<Position x="0", y="0"/>
</Item>
<Item name="item02">
<Position x="0", y="0"/>
</Item>
<Item name="item03">
<Position x="0", y="0"/>
</Item>
</Items>
The XmlDataProvider is declared as a resource as follows
<Window.Resources>
<XmlDataProvider x:Key="SiteConfigFile" XPath="SiteConfig" >
</XmlDataProvider>
</Window.Resources>
I then enable a combobox to show each item in the Xml file via a drop down menu using:
<ComboBox Name="ButtonMapping" ItemsSource="{Binding Source={StaticResource SiteConfigFile}, XPath=Items/Item}" DisplayMemberPath="@name" SelectedIndex="0">
This all works fine.
The problem I want to solve now is... depending on which item from the combo box is selected, the corresponding Position element with its 2 attributes need to be shown in atextbox on the gui... do i i need to generate dynamic XPath, that seems a bit messy... what is the best way to do this, I'm out of ideas :(