tags:

views:

5

answers:

0

I am trying to generate items in wrappanel defined in XML. I am missing something here. I got to the point that I can generate content from xml but it is duplicated. With the code below, I am getting 2 stackpanel with the same content. How to pass the two other values for Person node. Thank you in advance.

XML:

<?xml version="1.0" encoding="utf-8"?><persons xmlns="">
<Person>
    <FirstName>AAAA</FirstName>
    <LastName>AAAA</LastName>
</Person>
<Person>
    <FirstName>BBBB</FirstName>
    <LastName>BBBB</LastName>
</Person>
<Person>
    <FirstName>CCCC</FirstName>
    <LastName>CCCC</LastName>
</Person></persons>

XAML:

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

<Grid x:Name="LayoutRoot">
    <UserControl>

    <!-- local:UserControlWP/ -->

    <ItemsControl x:Name="list" ItemsSource="{Binding Source={StaticResource DashboardData}, XPath=persons/Person}">

            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Margin="20,20,10,20" Orientation="Vertical" >
                    </WrapPanel>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemTemplate>
                <DataTemplate x:Name="test">
                    <StackPanel Orientation="Vertical" Margin="0,10,10,0" DataContext="{Binding Source={StaticResource DashboardData}, XPath=/persons/Person}">
                        <TextBox Text="{Binding XPath=FirstName}" Width="50" />
                        <TextBox Text="{Binding XPath=LastName}" Width="50" />
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>

    </ItemsControl>

    </UserControl>