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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:29:56+00:00 2026-06-07T18:29:56+00:00

I have a query that returns 2 columns from joining 2 entities as the

  • 0

I have a query that returns 2 columns from joining 2 entities as the following:

var myQ = myDataContext1.Entity1.Join(myDataContext1.Entity2, a=>a.id, b=>b.id, (a, b)=> new Tuple<int, float>(a.id, b.something)).ToList(); 
MyDatagrid.ItemSources = myQ;

It worked fine. But my datagrid labels the 2 columns as ‘item1’ and ‘item2’. I tried to change them to the right names. So far I could not do it. I tried to use:

MyDatagrid.Columns.Add(new DataGridTextColumns{ Header = "Aheader", Binding= new System.Windows.Data.Binding("a.id");

All the data would disappear because the binding name must be wrong. But I have no idea what I should put following Binding…
Then, I tried

MyDataGrid.Columns[0].Header = "myID"

It does not work and tells me every time that there were no columns in the column collection. So I think the change of the header must happen after the datagrid is loaded and added an event:

MyDataGrid.loaded += (o, e) =>{MyDataGrid.Columns[0].Header = "myID"};

Still the same error….. Any idea what I should do here? Thanks.

  • 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-06-07T18:29:57+00:00Added an answer on June 7, 2026 at 6:29 pm

    The binding needs to be Item1 and Item2. You should also set AutoGenerateColumns to false and it is preferrable to define the columns in XAML. eg

    <DataGrid AutoGenerateColumns="False">
        <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding Path=Item1}" Header="Header 1"></DataGridTextColumn>
            <DataGridTextColumn Binding="{Binding Path=Item2}" Header="Header 2"></DataGridTextColumn>
        </DataGrid.Columns>
    </DataGrid>
    

    You might also be better off using an anonymous type instead of a tuple. That way the binding could be more meaningful.

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

Sidebar

Related Questions

I have a query that always returns one row, with many columns. I would
I'm using Sql-Server, and I have the below query which returns all columns that
I currently have a query that returns a list of columns, and one of
I have a SQL query that returns two columns - Title and Count. When
I have a query in MySQL that returns three columns, a Candidate's ID, the
I have a query like the following that returns the correct number of rows
I have a sub query that returns one column, showing as GroupType, I then
I have this query that returns the results by ordering it by focus.name ASC.
I have a query that returns me around 6 million rows, which is too
I have a query that returns Properties for Rent / Sale on their respective

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.