Bensespaxia
New Member
I am stumped. I have the following XML, I think it was taken from another StackOverflow question in fact.\[code\]<?xml version="1.0" encoding="utf-8" ?><HousingShapes><Shape Name="Rectangular" id="1/3"/><Shape Name="Circular" id="1/34" /><Shape Name="Triangular" id="1/23" /><Shape Name="Other Shape" id="1/15" /></HousingShapes>\[/code\]I have bound my data like this in XAML\[code\]<Window.Resources> <XmlDataProvider x:Key="xmlData" Source="d:\people.xml" XPath="HousingShapes"/></Window.Resources>\[/code\]And my ComboBox below\[code\] <ComboBox Height="23" HorizontalAlignment="Left" Margin="97,52,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Source={StaticResource xmlData}, XPath=./Shape}" DisplayMemberPath="@Name" SelectedValuePath="{Binding Source={StaticResource xmlData}, XPath=./Shape}" SelectedValue="http://stackoverflow.com/questions/13868611/@id" />\[/code\]I want the user to see 'Shape Name' i.e Rectangular in the combobox. This bit works. But I want the id to be used when adding the data. as a test, I wrote the following\[code\] private void button1_Click(object sender, RoutedEventArgs e) { MessageBox.Show(comboBox1.SelectedValuePath); }\[/code\]Expecting to see 1/3 when Rectangular was selected or 1/15 when 'Other Shape' was selected, but nothing.