views:

2651

answers:

2

I'm looking to create a progress bar that doesn't use the WPF default style, which uses a dashed display. All I want is a simple, "smooth style" progress bar. In other words, I don't want to progress bar to be dashed. I want it to use a solid colored bar.

What's the easiest way to do this?

I assumed this would be part of the default API but I haven't been successful playing with it so far. Among other things, I've attempted to set the foreground brush, which only give me the color, not the style of the drawn bar. Is there a way to do this that doesn't involve me overriding the default template (I suppose the most straightforward solution).

+3  A: 

The defualt styles for each OS in XAML files that are part of the framework. You can use this code below to force it to use the vista styles throughout the application even on XP:

<Window.Resources>  

    <ResourceDictionary Source="/PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml" />

</Window.Resources>

This will however change the defualt look of button and all other UI elements.

This is based on code from here

John
+1  A: 

The easiest way to do this that I could find was to simply borrow and modify a theme/style for the type of progress bar I wanted. This is very similar to John's suggestion but, in my case, I'm only enforcing a style for the progress bar control, not the entire interface. The CodePlex WPF themes project is an great resource for this type of thing.

Ken Wootton