Here is a small/basic but useful sample to create a progress bar in XAML that is updated when making a call to a RESTful web service using WebClient (in my case) for Silverlight from my book. The code can easily be put inside of a self contained Silverlight user control of its own, which would allow it to easily be used in multiple areas of the application. I’ll leave that part up to you :)
The following XAML creates an outer Border panel and an inner Border panel. The outer Border sets the boundaries of the horizontal progress bar. Set the width of the outer Border (named brdProgressBoundary) to whatever width you want. The bar will grows until it reaches this point. The inner Border (named brdProgressMeter) starts with a width of 0 and is incremented using the percentage from the web service’s DownloadProgressChanged event handler to increase its width until it reaches 100% (which is where I has the same width as the outer border). I used a LinearGradientBrush to create a slight color effect in the progress bar. You could add whatever type of content you want here.
The key to moving the progress bar is knowing when the progress has changed and by how much. When a call is made through WebClient to a remote web service, if an event handler is added to the DownloadProgressChanged event, the handler receives notification when the progress has changed. For example, the following code will increment the inner border’s width and display a the percentage complete in a TextBlock inside of the inner border. This handler will execute at intervals while the WebClient’s web request is moving along.
As you might imagine, you’ll need to initialize the state of the progress bar before each WebClient’s async call and you will need to hide the progress bar when it is no longer needed. Here is the Progress as it looks in process: