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 7550923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:20:37+00:00 2026-05-30T10:20:37+00:00

I want to add a column programatically to my datagrid and bind it. I

  • 0

I want to add a column programatically to my datagrid and bind it.

I have tried following examples on the web but cant get the data do be displayed.

I did have it working with columns declared in the xaml.

Here is the datagrid Xaml declaration:

<DataGrid Grid.Row="0" x:Name="dtgMain" AutoGenerateColumns="False" ItemsSource="{Binding}" RowHeight="25" SizeChanged="dtgMain_SizeChanged"></DataGrid>

Here is where I set the datacontext for the datagrid:

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.LoadXml(response);
                provider.Document = doc;
                provider.XPath = "/moo/response/data/load/panel";
                dtgMain.DataContext = provider;

Here is where I add the column:

DataGridTextColumn dc = new DataGridTextColumn();
            dc.Binding = new Binding("panelCode");
            dc.Header = "Job Number";
            dtgMain.Columns.Add(dc);

And here is an example of the xml:

<moo>
  <response>
    <data>
      <load count="2">true
        <panel index="10">
          <panelCode>100072
          </panelCode>
        </panel>
      </load>
    </data>
  </response>
</moo>
  • 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-30T10:20:38+00:00Added an answer on May 30, 2026 at 10:20 am

    Your column binding is not using XPath when it should it seems to me.

    dc.Binding = new Binding() { XPath = "panelCode" };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How could I want to add a column if not exist. I tried this
I want to achieve the following use the following command to add a column
I want to add a column to an existing legacy database and write a
I want to add a column to a gridview which contains button control. I
I want to add a button to each row of a column of an
I want to ask how to add a computed column in BIRT that compute
In a SharePoint list I want an auto number column that as I add
I have dbml with single table users i want add partial class for User
I have a website built with ASP.NET (3.5) and want add some level of
I have a list of string values that I want add to a hashtable

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.