Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

XML data binding with controls in a grid

$
0
0

This is my XML data:

<?xml version="1.0" encoding="utf-8" ?>
<Teams xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CountryList>
    <CountryName>UK</CountryName>
    <CountryName>USA</CountryName>
  </CountryList>
  <Team>
    <Name>Arizona Cardinals</Name>
  </Team>
  <Team>
    <Name>Atlanta Falcons</Name>
  </Team>
</Teams>

How to fill tow listboxes one with name and another with CountryName.

I tried below

 <Grid.DataContext>
            <XmlDataProvider x:Name="TeamData" Source="Data\XMLData.xml"/>
        </Grid.DataContext>

<Window.Resources>
        <DataTemplate x:Key="teamItemTemplate">
            <Label Content="{Binding XPath=//Teams/Team/Name}"/>
        </DataTemplate>
        <DataTemplate x:Key="CountryListTemplate">
            <Label Content="{Binding XPath=//Teams/CountryList/CountryName}"/>
        </DataTemplate>
    </Window.Resources> 

But it adds only the first data.

Please help..


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>