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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:22:06+00:00 2026-06-12T06:22:06+00:00

I have an object similar to class Quote { string Ticker {set; get; }

  • 0

I have an object similar to

class Quote
{
    string Ticker {set; get; }
    string Rating {set; get;}
    People Sender {set; get;}
}

Peaple is defined as,

class People
{
    string Email {set; get;}
    int Age {set; get;}
    string Firm {set; get;}
}

I also have an ObservableCollection of Quote,

ObservableCollection <Quote> QuoteList;

Now I would like to display the QuoteList in a DataGrid, such that each row have the following 3 cells,
1. Quote.Ticker
2. Quote.Rating
3. Quote.Sender.Email

I also would like to, if I click each row, I can get the Quote object of that clicked row.
May I ask how can I achieve that?

  • 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-12T06:22:07+00:00Added an answer on June 12, 2026 at 6:22 am

    If you bind your DataGrid to an ItemsSource of an ObservableCollection<Quote> each DataGridRow will be built with the Quote object as it’s DataContext (data layer).

    By default, a DataGrid will automatically generate a column for each property on the data item, so in your case it would generate a column for Ticker, Rating, and Sender.

    You can either override that by setting AutoGenerateColumns="False" and defining your own <DataGrid.Columns>, which includes a column bound to Sender.Email

    <DataGrid ItemsSource="{Binding Quotes}" AutoGenerateColumns="False">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Ticker"  Binding="{Binding Ticker}"/>
            <DataGridTextColumn Header="Rating"  Binding="{Binding Rating}"/>
            <DataGridTextColumn Header="Email"  Binding="{Binding Sender.Email}"/>
        </DataGrid.Columns>
    </DataGrid>
    

    or you can use an implicit DataTemplate to tell WPF to draw the Sender object with a string containing the Email property

    <DataGrid ItemsSource="{Binding Quotes}">
        <DataGrid.Resources>
            <DataTemplate TargetType="{x:Type local:People}">
                <TextBlock Text="{Binding Email}" />
            </DataTemplate>
        </DataGrid.Resources>
    </DataGrid>
    

    Of the two, I’d pick the first one for your situation since you won’t need to code anything extra for things like editing

    As for getting the data object when the row is clicked, simply check out the DataContext of the row, or bind your CommandParameter to "{Binding }"

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

Sidebar

Related Questions

I have a command object: public class Job { private String jobType; private String
I have a model similar to this: public class myModel { public ClassA ObjectA
I have a data.table object similar to this one library(data.table) c <- data.table(CO =
I have an object with large number of similar fields (like more than 10
I have an object with event handlers and I want to make something similar
Why two object's hash code is not same even though they have similar values.
I have a JavaScript object that is similar to this: var MyClass; MyClass =
Currently I have a lot of python objects in my code similar to the
I have object A which contains multiple instances of object B, which in turn
I have two tables: object that has object_id column and avalues that have object_id

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.