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

  • Home
  • SEARCH
  • 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 7079407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:40:07+00:00 2026-05-28T06:40:07+00:00

I have a WPF data grid and an xmlString and am having problems binding

  • 0

I have a WPF data grid and an xmlString and am having problems binding it.

I have read this post and followed the instructions but cant get it to work.

I see the column with the title but no data is in there. Any ideas?

I should say the code behind is called when a button is clicked after the window has loaded.

Here is my XAML

<DataGrid x:Name="dtgMain" ItemsSource="{Binding Path=Elements[panel]}">
    <DataGrid.Columns>
        <DataGridTextColumn Header="PanelCode" Binding="{Binding Path=Element[panelCode].InnerText}"/>
    </DataGrid.Columns>
</DataGrid>

Here is my codebehind

System.IO.StringReader reader = new System.IO.StringReader(response);
            XElement results = XElement.Load(reader);
            dtgMain.DataContext = results;

here is my xml

<data>
  <load count="2">true
    <panel index="10">
      <panelCode>100072
      </panelCode>
      <panelName>COM0100072*A
      </panelName>
      <panelPart>100072
      </panelPart>
      <numberLayers>4
      </numberLayers>
      <panelSize.display>21.0 x 24.0
      </panelSize.display>
      <lastEdited.display>16/11/2011 17:13:39
      </lastEdited.display>
      <panelStatus.display>Measurements Stored
      </panelStatus.display>
      <lastEditor>admin
      </lastEditor>
      <numberBonds>1
      </numberBonds>
      <numberSubComponents>0
      </numberSubComponents>
    </panel>
    <panel index="11">
      <panelCode>100352
      </panelCode>
      <panelName>COM0100352*C
      </panelName>
      <panelPart>100352
      </panelPart>
      <numberLayers>8
      </numberLayers>
      <panelSize.display>18.0 x 24.0
      </panelSize.display>
      <lastEdited.display>16/11/2011 17:18:47
      </lastEdited.display>
      <panelStatus.display>Measurements Stored
      </panelStatus.display>
      <lastEditor>admin
      </lastEditor>
      <numberBonds>1
      </numberBonds>
      <numberSubComponents>0
      </numberSubComponents>
    </panel>
  </load>
</data>
  • 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-28T06:40:08+00:00Added an answer on May 28, 2026 at 6:40 am

    XElement does not have an ‘InnerText’ property.

    Have you tried using

    Binding="{Binding Path=Element[panelCode].Value}"
    

    instead?

    Edit:

    I just tested with a sample project and the only other change (besides using .Value) is changing your ItemsSource of your DataGrid to include the ‘load’ node:

    ItemsSource="{Binding Path=Element[load].Elements[panel]}"
    

    So your data grid will look like the following:

    <DataGrid x:Name="dtgMain" ItemsSource="{Binding Path=Element[load].Elements[panel]}">
        <DataGrid.Columns>
           <DataGridTextColumn Header="PanelCode" Binding="{Binding Path=Element[panelCode].Value}"/>
        </DataGrid.Columns>
    </DataGrid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where I am using wpf data binding and validation using
I have created a data grid in WPF and have 2 lists. I want
I am using WPF datagrid. Data I am binding to the grid is not
I have a WPF Data Grid (From the WPF Toolkit as the title indicates)
Is it possible to have a WPF Toolkit Data Grid's DataGridComboBoxColumn exposed when the
I have a .Net 4.0 WPF application using a data grid. Currently after sorting
I have a WPF Grid with a XAML similar to this: <Grid width=200 Height=200
Is it possible to have a pure hierarchical wpf data grid? Now there are
I have a WPF ListView which repeats the data vertically. I cannot figure out
I have a WPF ListBox bound to a data object. Inside the listbox are

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.