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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:23:14+00:00 2026-06-15T14:23:14+00:00

I got a problem with the designpattern MVVM. In my View i got a

  • 0

I got a problem with the designpattern MVVM.
In my View i got a Datagrid with an binding to a datatable in my viewmodel.

        <WPF:BADataGrid Grid.Column="1" x:Name="dgStapelliste" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Stapelliste, Mode=OneWay}"/>

In my constructor of the viewmodel I load the ItemsSource.

        this.StapelListe = this._stapel.Get();

If I add some additional rows during runtime via a button everything works fine.
But I don´t want to push a button to refresh the datagrid, I want it to happen automatically in a thread or background worker.

Here´s some test example:

        BackgroundWorker worker = new BackgroundWorker();
        worker.DoWork += delegate(object s, DoWorkEventArgs args)
        {
            while (true)
            {
                Thread.Sleep(5000);

                DataRow row = this.StapelListe.NewRow();
                row["StapelNr"] = 123456;
                this.StapelListe.Rows.Add(row);
            }
        };

THIS won´t work… and I don´t know why… the rows are added in the datatable “StapelListe” but the datagrid is not going to refresh itself…

If I change an existing row in the datatable in a thread it works! It just doesn´t work with adding or removing rows from the collection.

Someone got an idea why this happens and/or how to resolve it?

Kind regards…

  • 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-15T14:23:15+00:00Added an answer on June 15, 2026 at 2:23 pm

    As MegaMind wrote, the View needs to know that something has changed. If you are adding new Rows to an existing DataTable, the View never gets notified that something has been added. So you should use a collection which was made for that: ObservableCollection<T>.

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

Sidebar

Related Questions

I got problem to request a PartialView using ajax In my point of view
Hello I got problem with scroll on my grid. Here is the code (nothing
I have got problem with django's UserCreationForm. It's very strange because ween I: view:
i got problem with my code and hopefully someone able to figure it out.
I got problem with sending data in Android using httpPost. I found some example,
I've got problem with DirectX in C#. I want to draw some lines. Firstly
I've got problem for my application. I want to start connectbot from my application
I've got problem with connecting to MySQL database on my freshly installed Windows 7
have a nice day. I got problem when trying to create an image from
I want to ask about strcpy. I got problem here. Here is my code:

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.