Rick wrote:
Quote:
I'm using WPF with net 3.5 to load the ItemsSource of a combo box from
an xml file.
>
The xml is setup like this:
>
<profiles>
<profile>
<profilename>First profile</profilename>
...
</profile>
... other profile nodes
</profiles>
>
In the Windows.Resources node of the xaml I have:
>
<XmlDataProvider x:Key="xmldata" Source="c:/temp/xmlData.xml"
XPath="profiles/profile" />
>
and in the combobox I have:
>
<ComboBox Margin="5" Name="cbProfiles" Width="240" IsEditable="True"
ToolTip="Select database profile"
VerticalContentAlignment="Center"
ItemsSource="{Binding Source={StaticResource
xmldata}, XPath=profilename }" SelectedIndex="0" />
>
But this only retreives the first profile-profilename for the combobox
list. If I change the XPath of the combobox to //profilename, then I get
them all.
>
What am I not understanding about how this works since I think the XPath
of the XmlDataProvider should be providing a list of <profiles/profile>
nodes and then the XPath of the combobox should give me all the
<profilenamenodes.
|
I think you want
<XmlDataProvider x:Key="xmldata" Source="c:/temp/xmlData.xml"
XPath="profiles" />
and
<ComboBox Margin="5" Name="cbProfiles" Width="240" IsEditable="True"
ToolTip="Select database profile"
VerticalContentAlignment="Center"
ItemsSource="{Binding Source={StaticResource
xmldata}, XPath=profile/profilename }" SelectedIndex="0" />
As far as I understand it, the XPath on the XmlDataProvider selects a
single node as the context node, then a relative XPath on the
ItemsSource of the ComboBox selects a list of nodes relative to that
content node.
If you use an absolute XPath like //profilename then you are basically
ignoring the XPath set on the XmlDataProvider.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/