Update progress bar on wpf data binding (in C #)
EDIT - After playing around with a bunch of potential solutions (using a background worker and separate threads), I found that the key issue here is that the data binding is "breaking". Since the progress bar is an animated circle (not a full percentage), it has to respond to the timer event at equal intervals in order to animate smoothly (which is why I can't bind the data one at a time and then send a progress update to the ui thread). Does anyone know what animation needs to be done when data binding occurs? Thanks again for entering!
Original Q -
I am associating a large dataset with a WPF list box which can take a long time (over ten seconds). While the data is being bound, I would like to display a circular progress bar
I cannot get the progress bar to show while the data binding is in progress, although I am trying to make the binding in the backgroundworker. I tested it by making the first line of the background dowork a Thread.Sleep event (5000) and of course the progress bar started spinning for that duration only to freeze when the binding started.
Is it because both data binding and UI updating must happen on the same thread? Any ideas on how to get around this?
Thanks for the help!
a source to share
Use the adorner layer and place a progress bar in it that will allow it to overlay and respond to controls on the screen. Load the data back in and periodically refresh the control that displays your results (I also recommend using the virtualization pane as the toolbox). This way, you can keep the progress bar in foreground on a timer for animation, and pipe the incoming data into the results view with a dispatcher and degat. We implemented a similar solution for the client (big arrangements of data coming through java webservices and buffered to grid-progressive discolsure;)) and it worked like a champion.
a source to share
For a good introduction to working with WPF Dispatcher and progress bar, see CodeProject: WPF ProgressBar
This article is rather short, but it is a great starting point for updating the WPF interface while the work needs to be done in the background.
Remember, by default, all work is done on the UI thread in WPF.
a source to share