Jayme65 0 Newbie Poster

I have an XML file structured this way:

<Emulators>
  <Settings>
    <vol name="10"/>    
    <Volume>10</Volume>
    <Keys name="key1" value="1" />
    <Keys name="key2" value="2" />
    <Keys name="key3" value="3" />
    <Keys name="key4" value="4" />
  </Settings>
  <System>
    <Name>name1</Name>
    <Icon>name1.png</Icon>
    <topplayed>
      <Top>top1</Top>
      <Top>top2</Top>
      <Top>top3</Top>
    </topplayed>
  </System>
<System>
    <Name>name2</Name>
    <Icon>name2.png</Icon>
    <topplayed>
      <Top>top4</Top>
      <Top>top5</Top>
      <Top>top6</Top>
    </topplayed>
  </System>
</Emulators>

I get no difficulties binding to <Settings> tag, as well as tags contained into it (lines 24,25,26).
I get no difficulties to bind the <System> tag into a list box (line 27).....but I don't know how to bind to tags into <topplayed> (line 28).
How to populate a listbox with all <topplayed> elements of the currently selected <System>?

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApplication1"         
    Title="MainWindow" Height="721" Width="525" Background="#FF4E4E64">
    <Grid Name="Grid1">
        <Grid.DataContext>
            <XmlDataProvider x:Name="SystemData" Source="C:\Users\Portable\Desktop\taper\WpfApplication1\Resources\Systems2.xml" XPath="Emulators" />
        </Grid.DataContext>
        <Grid.Resources>
            <DataTemplate x:Key="Resource1">
                <Label Content="{Binding XPath=@name}"/>
            </DataTemplate>
            <DataTemplate x:Key="Resource2">
                <Label Content="{Binding XPath=@value}"/>
            </DataTemplate>
            <DataTemplate x:Key="Resource3">
                <Label Content="{Binding XPath=Name}"/>
            </DataTemplate>
            <DataTemplate x:Key="Resource4">
                <Label Content="{Binding XPath=Top}"/>
            </DataTemplate>
        </Grid.Resources>
        <TextBox Text="{Binding XPath=Settings/Volume}" Height="30" HorizontalAlignment="Left" Margin="12,12,0,0" Name="TextBox5" VerticalAlignment="Top" Width="196" />
        <ListBox ItemsSource="{Binding XPath=Settings/Keys}" ItemTemplate="{StaticResource Resource1}" IsSynchronizedWithCurrentItem="True" Height="92" HorizontalAlignment="Left" Margin="12,48,0,0" Name="ListBox1" VerticalAlignment="Top" Width="196" />
        <ListBox ItemsSource="{Binding XPath=Settings/Keys}" ItemTemplate="{StaticResource Resource2}" Height="92" HorizontalAlignment="Left" IsSynchronizedWithCurrentItem="True" Margin="214,48,0,0" Name="ListBox2" VerticalAlignment="Top" Width="196" />
        <ListBox ItemsSource="{Binding XPath=System}" ItemTemplate="{StaticResource Resource3}" IsSynchronizedWithCurrentItem="True" Height="104" HorizontalAlignment="Left" Margin="12,185,0,0" Name="ListBox3" VerticalAlignment="Top" Width="196" />
        <ListBox ItemsSource="{Binding XPath=System/topplayed}" ItemTemplate="{StaticResource Resource4}" Height="74" HorizontalAlignment="Left" Margin="12,295,0,0" Name="ListBox4" VerticalAlignment="Top" Width="196" />
    </Grid>
</Window>

Thank you very much!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.