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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:38:50+00:00 2026-06-04T01:38:50+00:00

I have a datagrid bound to an ObservableCollection<MyClass> , and I have another datagrid

  • 0

I have a datagrid bound to an ObservableCollection<MyClass>, and I have another datagrid which has two DataGridTextColumns – Name and Value. The Name column is prepopulated with the names of properties whose values should be displayed in the Value column. MyClass implements INotifyPropertyChanged, so any change in the properties of MyClass objects updates the first datagrid. Now, I would like to display the properties of the currently selected object (SelectedItem) of the first datagrid in the Value column of the second datagrid and see the property changes as they happen, like in the first datagrid. How can I accomplish this?

If you wonder about the reason, only some of the properties are displayed in the original datagrid, so the other one should display almost all of them. Is datagrid even a good choice for displaying properties in 2 columns or should I consider some other control?

  • 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-04T01:38:52+00:00Added an answer on June 4, 2026 at 1:38 am

    This sounds like one convenient solution to a fairly common problem.

    The easiest way to do this with two data grids will be for you to use some code behind and reflection. First define a type to display the Name and value of each property:

    class PropertyModel {
        private readonly string _name = "";
        private readonly object _value = null;
    
    
        public PropertyModel(string name, object value) {
           _name = name ?? "";
           _value = _value;
        }
    
        public string Name {
            get { return _name; }
        }
    
        public object Value {
            get { return _value; }
        }
    }
    

    Then add an event handler to your code-behind to handle selection changes on your first datagrid:

    private void _onDataGrid1SelectionChanged(object sender, SelectedCellsChangedEventArgs e) {
       if (e.AddedCells.Count > 0) {
            var props = new Collection<PropertyModel>();
            var obj = _dataGrid1.SelectedItem;
            foreach(var prop in obj.GetType().GetProperties()) {
                props.Add(new PropertyModel(prop.Name, prop.GetValue(obj, null)));
            }
    
    
            _dataGrid2.ItemsSource = props;
       }
    
    }
    

    Note that the code above is very rough, and will only work if DataGrid1 has SelectionMode set to Single. However this is a good place to start, if you are willing to do it quick and dirty (with an event handler).

    Another great solution is to use row details.
    This is a pretty good intro tutorial on using row details.
    Of course you should also read the msdn article on the subject.

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

Sidebar

Related Questions

I have a View that displays a DataGrid which is bound to an ObservableCollection
I have a DataGrid which is being bound dynamically to a database query. The
I have a problem with a data-bound DataGrid control, in that despite each column
Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#.
I have a DataGrid where each column has a SortExpression. I would like the
I have a datagrid bound to an ObservableCollection, and what I'd like to do
I have a WPF DataGrid bound to ObservableCollection . Each item in my collection
I have a DataGrid bound to a ViewModel's property of type ObservableCollection. Inside DataGrid
I have a datagrid that is bound to a observableCollection of Employees The user
I have an ObservableCollection bound to a WPFToolkit DataGrid in an MVVM pattern. Every

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.