0

I have an xml file that looks something like this

<Data>
  <NumberID>23423</NumberID>
  <NumberID>34234</NumberID>
  <NumberID>45435</NumberID>
</Data>

How do I display a specific node on a textbox control? Currently I'm trying to show the second "NumberID" from my XML file:

<Window.Resources>
        <XmlDataProvider x:Key="RoutingData"
               Source="/RoutingLogic.xml"
               XPath="Data/NumberID[2]"/>         
</Window.Resources>

...

<TextBox Text="{Binding ElementName=RoutingData}">

But it's now showing anything. What am I doing wrong?

MVZ
  • 2,220
  • 5
  • 27
  • 57

1 Answers1

0

I figured it out. I changed the binding info to this:

<Window.Resources>
        <XmlDataProvider x:Key="RoutingData"
               Source="/RoutingLogic.xml"
               XPath="Data"/>         
</Window.Resources>

...

<TextBox Text="{Binding Source={StaticResource RoutingData}, XPath=NumberID[2]}"/>
MVZ
  • 2,220
  • 5
  • 27
  • 57