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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:12:34+00:00 2026-05-24T14:12:34+00:00

I have a datagrid in my wpf application and I have a simple problem.

  • 0

I have a datagrid in my wpf application and I have a simple problem. I have a generic list and I want to bind this collection to my datagrid data source every time an object is being added to the collection. and I’m not interested to use observable collection.

the point is I’m using the same method somewhere else and that works fine. but this time when i press Add button an object is added and datagrid updates correctly but from the second item added to collection datagrid does not update anymore.

Here is the Code :

 private void btnAddItem_Click(object sender, RoutedEventArgs e)
    {
        OrderDetailObjects.Add(new OrderDetailObject
        {
            Price = currentitem.Price.Value,
            Quantity = int.Parse(txtQuantity.Text),
            Title = currentitem.DisplayName,
            TotalPrice = currentitem.Price.Value * int.Parse(txtQuantity.Text)
        });

        dgOrderDetail.ItemsSource = OrderDetailObjects;
        dgOrderDetail.UpdateLayout();
    }

any idea ?

  • 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-24T14:12:35+00:00Added an answer on May 24, 2026 at 2:12 pm

    The ItemsSource is always the same, a reference to your collection, no change, no update. You could null it out before:

    dgOrderDetail.ItemsSource = null;
    dgOrderDetail.ItemsSource = OrderDetailObjects;
    

    Alternatively you could also just refresh the Items:

    dgOrderDetail.ItemsSource = OrderDetailObjects; //Preferably do this somewhere else, not in the add method.
    dgOrderDetail.Items.Refresh();
    

    I do not think you actually want to call UpdateLayout there…

    (Refusing to use an ObservableCollection is not quite a good idea)

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

Sidebar

Related Questions

I have a problem with my WPF application. I have a datagrid (Wpf Toolkit),
I have a DataGrid control in a WPF application. I want to be able
I have a WPF/MVVM application with a DataGrid on a window. I want to
I have a layout problem with a datagrid in my C# WPF application. If
I have a strange problem with a WPF DataGrid from WPF Toolkit. The scrollbars
I have developed a simple DB-editing app using Xceed's excellent DataGrid for WPF (UX
I am making a WPF-application.I have a datagrid with a column header that contains
I have a WPF application with a datagrid who's ItemsSource is a BindingList. When
I have a DataGrid in a WPF application that binds itself to an ObservableCollection
I have a WPF application which shows items in a DataGrid (XCeed DataGrid). The

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.