UI DataGrid not updating when adding Item to ObservableCollection

Nov 2 2021 10:11 AM

I'm creating a FileSystemWatcher with WPF MVVM pattern. When watcher is started it gets the oldest *.json file from the Input folder and the file gets copied to the Output folder I activate a external program `Autodesk Inventor` that reads the *.json file and makes the 3D model and 2D drawings and so on. 

I have 2 ObservableCollections<File> that are shown in a DataGrid in my UI. But when I make changes during my code, adding and removing items from the collection  the UI doesn`t update right away, it only changes after my StartProcess() method ends.

How can I make this that the UI makes the changes and shows the changes in the collection right away? 

How it works, start debugging, set the input and output folder (i created a input and output folder in the debug folder). When in debugmode the solution checks for simple .txt files (these are in the inputfolder) press START in the right corner to start the watcher it will move the oldest file to the output folder start the process (in debugmode Thread.Sleep(15000)). In debugmode copy the Example1_OK.txt in the inputfolder and the process will start again. My issue is that the UI does not update untill the process is done wich is very confusing for the end user.

I tried using backgroundworkers and Dispatcher but no results

Thanks in advance

 

 


Attachment: APM_Example.zip