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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:37:31+00:00 2026-06-09T22:37:31+00:00

I have the following datagrid in a wpf form: <DataGrid Name=DataGrid AutoGenerateColumns=False VerticalScrollBarVisibility=Auto> <DataGrid.Columns>

  • 0

I have the following datagrid in a wpf form:

<DataGrid Name="DataGrid" AutoGenerateColumns="False" VerticalScrollBarVisibility="Auto">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Name" Width="200"></DataGridTextColumn>
        <DataGridTextColumn Header="Text" Width="200"></DataGridTextColumn>
        <DataGridTemplateColumn Header="Edit" Width="50">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Button>View Details</Button>
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>

And I’d like to populate it from my code. I use a linq statement to get the values I’d like to put in the datagrid

var query =
    (
        from modules ...
        join ...
        join ...
        where ...
        select new { ID = modules.ID, Name = strings.Name, Text = stringTexts.Text }
    );

I’d like to populate the columns ‘Name’ and ‘Text’ with Name and Text from the query, but I also want there to be a button in each row, and when that button is pressed, I have to know the ID of the row that was pressed, but the ID does not have to show up on the grid.

How do I populate the grid with these values?

  • 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-09T22:37:32+00:00Added an answer on June 9, 2026 at 10:37 pm

    Tell columns to bind to a property using

    <DataGridTextColumn Header="Name" Width="200" Binding="{Binding Name}" />
    

    and so on for other columns.

    Then in code behind

    DataGrid.ItemsSource = query;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XAML Code: <sdk:DataGrid Margin=58,8,52,18 Name=dataGridTickets> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn x:Name=ticketNoColumn Header=Ticket No.
I have following DataGrid in wpf. <DataGrid AutoGenerateColumns=False Grid.Row=1 Name=adsGrid ItemsSource={Binding Path=Ads} CanUserAddRows=False CanUserDeleteRows=False
I have a following XAML: <DataGrid Name=nodeDataGrid ItemsSource={Binding NodeList} AutoGenerateColumns=False RowBackground=White AlternatingRowBackground=AliceBlue Grid.Column=1 HorizontalAlignment=Stretch
I have the following XAML: <StackPanel> <StackPanel Orientation=Horizontal> <Border Name=B1 Width=Auto> <DataGrid /> </Border>
I have the following DataGrid <DataGrid> <DataGrid.Columns> <DataGridTextColumn Header=Registro Binding={Binding NumeroRegistro} /> <DataGridTextColumn Header=Nome
E.g. I have following datagrid <mx:DataGrid x=331 y=16 height=132 width=419 id=me_claimed dataProvider={users.myclaims} useRollOver=false> <mx:columns>
I want to achieve the following: Create a WPF DataGrid that have 2 columns:
I have the following xaml code defined for DataGridTextColumn of a DataGrid. <DataGridTextColumn x:Name=UserIdColumn
I have a following table ------------ id name ------------ 1 master 2 datagrid 3
I have the following XAML markup in a WPF DataGrid: <DataGrid ItemsSource={Binding ResultList} Grid.ColumnSpan=4

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.