Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 991837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:10:20+00:00 2026-05-16T06:10:20+00:00

I have a xml like this: <root> <project name=p1> <row field1=31 field2=3 Name=Joe/> <row

  • 0

I have a xml like this:

<root>
<project name="p1">
 <row field1="31" field2="3" Name="Joe"/>
  <row field1="39" field2="3" Name="Joey"/>
  <row field1="37" field2="3" Name="Joei"/>
</project>
<project name="p2">
 <row field1="31" field2="3" Name="Joe"/>
  <row field1="39" field2="3" Name="Joey"/>
</project>
</root>

Now the listbox displays the projects. When a project is selected in listbox, a grid has to display the rows. Is it possible to do this in Xaml? Or should i do it in the code as part of listbox’s selectionChanged Event?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:10:21+00:00Added an answer on May 16, 2026 at 6:10 am

    Yes. Just name your ListBox, bind the DataGrid’s DataContext property to the ListBox’s SelectedItem property, then set the ItemsSource of the DataGrid to the corresponding xml node.

    See the code below. It uses a ListView, though, instead of a DataGrid.

    <Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <XmlDataProvider x:Key="data">
            <x:XData>
                <root xmlns="">
                    <project name="p1">
                        <row field1="31" field2="3" Name="Joe"/>
                        <row field1="39" field2="3" Name="Joey"/>
                        <row field1="37" field2="3" Name="Joei"/>
                    </project>
                    <project name="p2">
                        <row field1="31" field2="3" Name="Joe"/>
                        <row field1="39" field2="3" Name="Joey"/>
                    </project>
                </root>
            </x:XData>
        </XmlDataProvider>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="3*"/>
        </Grid.ColumnDefinitions>
    
        <ListBox x:Name="listBox" ItemsSource="{Binding Source={StaticResource data}, XPath=root/project}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding XPath=@name}"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    
        <ListView Grid.Column="1" DataContext="{Binding ElementName=listBox, Path=SelectedItem}" ItemsSource="{Binding XPath=row}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Field1" DisplayMemberBinding="{Binding XPath=@field1}"/>
                    <GridViewColumn Header="Field2" DisplayMemberBinding="{Binding XPath=@field2}"/>
                    <GridViewColumn Header="Field3" DisplayMemberBinding="{Binding XPath=@Name}"/>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some xml like this: <Data> <Rows> <Row> <Field Name=title>Mr</Field> <Field Name=surname>Doe</Field> <Row>
I have an xml like this: <root> <row col1=value1 col2=value2 ...... coln=valuen/> <row col1=value1
Hi I have an xml document like this <root> <cert id=1> </cert> <cert id=2>
I have a RelativeLayout with one child as <include another.xml> like this root.xml :
I have got an XML document which looks something like this. <Root> <Info>....</Info> <Info>....</Info>
I have xml like this: <configurationData> <path name='b'> <path name='a'> <setting name='s1'> ![CDATA[XXXX]] </setting>
I have xml structure like this: <Group id=2 name=Third parentid=0 /> <Group id=6 name=Five
I have an Xml like this: <root> <item> <content type=HTML> <![CDATA[<html> <head></head> <body>something goes
I have an xml like this: <root> ... <images xmlns:a=http://.../Arrays> <a:string>http://images...233/Detail.jpg</a:string> <a:string>http://images....233/Detail2.jpg</a:string> </images> ...
Let say that I have xml like this: <root> <node light=somevalue>message1</node> <node dark=somevalue>message2</node> <node>message3</node>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.