views:

662

answers:

1
+1  A: 

I'm not quite sure how you intend the progressbar to combine different progresses, but if say the furthest along progress is at the bottom of the z-index and the least along progress is at the top, then I'd do something on the lines of this:

1) I would probably create a user control for this new progresbar.

2) It would have a property called NumberOfProgresses, that is tied with an array containing status of said progresses.

3) Each progress would be represented by a Border item (or perhaps something more suitable up the visual tree), because it's a simple wpf control with a background property. The background property would be set to nice a looking progress style and the progress color can be bound in the style to say the border's borderbrush property. Making it easy to set the color of the progress.

4) The user control would have a method UpdateProgress which takes the percentage value and the index of the progress in the array as parameters.

5) As progresses are updated you can either, just calculate the appropriate width (user control actual width * percentage) for the border and play around with the Z index to get it displayed at the top/bottom, or stack the borders horizontaly, set the least along progress as first, then for the rest of the progresses you'd have to substract previous progresses lengths to get the same effect.

This way there would be no transparency induced artifacts and no OnRender()... Mind you, in WPF there should be no reason to mess with OnRender this and OnRender that, like it was required in WinForms with OnPaint. Just set up the elements via code to get the look you want, and let WPF do it's rendering ;)

I can imagine one problem with this user control though. You'd have to provide feedback to the user as to which color belongs to which progress. But that would probably take you back to square one, meaning it's better/simpler to just display multiple progressbars.

Marko
So, this would probably be purely as a .cs file?
Tom
Depends on how you go about creating the user control. If you don't intend to reuse it in other apps, then you'd probably add a new wpf UserControl to your solution, which consists of xaml and cs. In the xaml part you'll define the basic layout of things, mainly the container for the border items that represent progresses. And in the cs file you'l write code that actually creates new borders and places them into the container, also the update progress method...
Marko