Reputation: 2958
i'm trying hard to load comboBox items from an xml file. Here is my code:
<Grid>
<Grid.Resources>
<XmlDataProvider x:Key="ScenesXml" XPath="scenari-list/scenario" Source="http://192.168.40.18/LeafHouse/scenari-appartamento-5.xml"/>
</Grid.Resources>
<ComboBox Name="scenariCombo" VerticalAlignment="Center" Width="120"
ItemsSource="{Binding Source={StaticResource ScenesXml}}" DisplayMemberPath="@name" />
</Grid>
And here is a simplified version of the xml file:
<scenari-list>
<scenario name="Fuori casa" value="fuori-casa">
...
</scenario>
<scenario name="Party" value="party">
...
</scenario>
<scenario name="ciao" value="ciao">
...
</scenario>
</scenari-list>
I want scenario's names to appear inside the combobox.
I found the code i provided in lots of questions but it doesn't work for me.
Anyone can help?
Upvotes: 0
Views: 665
Reputation: 184376
XML is case-sensitive, so @Name
should not yield any results as the attribute's name is name
.
=> DisplayMemberPath="@name"
Upvotes: 2