C#C
C#16mo ago
Dingus

Updating datagrid gui from other threads

In wpf, I have an application that has a button and datagrid. The button over the datagrid adds an object to the datagrid called barProgress. The class barProgress contains one public int value called progress and is a default of 0 when initialized. The datagrid itself has two columns. Column one contains a progress bar for each object and Column two has a button that tells the progress of object to go up by one every second.

I understand creating/adding/binding objects to the datagrid and their values. I added background workers (running async of course) per object to update the object.progress by one per second.

Here's the problem.
I do not understand how to update the gui other than calling a method to refresh the ENTIRE datagrid. If I refresh the datagrid have issues with the buttons associated with each object being unable to be used the split second the datagrid refreshes.

Is there a concept I am missing? I do not have an observable collection or notify changes property for the class of bar progress. I believe that is what I need but I also cannot find a good example of how those work and I wonder that even if I get those to work does that mean the button per object is still going to refresh and be disabled for a split second?

This is my code.

This is just a demo for this specific issue that pertains to a much bigger project I have where refreshes are much more rapid and button access really matters.
app.PNG
GitHub
Contribute to Dingus115/multithreaded-Datagrid development by creating an account on GitHub.
Was this page helpful?