Reputation: 70324
I'm using the ProgressBar control in a WPF application and I'm getting this old, Windows 3.1 ProgressBlocks thing. In VB6, there was a property to show a smooth ProgressBar. Is there such a thing for WPF?
Upvotes: 6
Views: 24792
Reputation:
I was not able to find a direct solution for this. But I found something even better. In WPF, you can use Windows Themes. I am using Windows XP, and having Vista-Aero Theme on my WPF Application, making all controls look like Vista-Aero.
Here's the code...
Go to Application.xaml.vb and write...
Enum appThemes
Aero
Luna
LunaMettalic
LunaHomestead
Royale
End Enum
Private Sub Application_Startup(ByVal sender As Object, ByVal e As System.Windows.StartupEventArgs) Handles Me.Startup
setTheme(appThemes.Aero)
End Sub
''' <summary>
''' Function to set the default theme of this application
''' </summary>
''' <param name="Theme">
''' Theme of type appThemes
''' </param>
''' <remarks></remarks>
Public Sub setTheme(ByVal Theme As appThemes)
Dim uri As Uri
Select Case Theme
Case appThemes.Aero
' Vista Aero Theme
uri = New Uri("PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\\themes/Aero.NormalColor.xaml", UriKind.Relative)
Case appThemes.Luna
' Luna Theme
uri = New Uri("PresentationFramework.Luna;V3.0.0.0;31bf3856ad364e35;component\\themes/Luna.NormalColor.xaml", UriKind.Relative)
Case appThemes.LunaHomestead
' Luna Mettalic
uri = New Uri("PresentationFramework.Luna;V3.0.0.0;31bf3856ad364e35;component\\themes/Luna.Metallic.xaml", UriKind.Relative)
Case appThemes.LunaMettalic
' Luna Homestead
uri = New Uri("PresentationFramework.Luna;V3.0.0.0;31bf3856ad364e35;component\\themes/Luna.Homestead.xaml", UriKind.Relative)
Case appThemes.Royale
' Royale Theme
uri = New Uri("PresentationFramework.Royale;V3.0.0.0;31bf3856ad364e35;component\\themes/Royale.NormalColor.xaml", UriKind.Relative)
End Select
' Set the Theme
Resources.MergedDictionaries.Add(Application.LoadComponent(uri))
End Sub
(I hope you can convert it to C#)
Upvotes: 2
Reputation: 3358
I recently was annoyed by the appearance of my progress bars on XP after developing on Vista. I didn't want to try suggestions I'd seen for loading the Vista styles out of dll's, but this article gave me just what I was looking for. vista appearance - no new classes. Plus it has the glassy highlight on a timer. No pictures on the article, but it looks just like Vista's ProgressBar.
Upvotes: 0
Reputation: 881
I am not sure what you want to do. If you simply want a progress bar that "sweeps" from side to side like on starting Vista you could use: IsIndetermined = true.
If you actually want to go from 0% to 100% you have to either animate over the value as shown in this example on msdn: http://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar.aspx or set the value explicitly either in code-behind (most likely from a background worker) or through a binding to a changing value.
Nevertheless the WPF ProgressBar should always be "smooth", there is the possibility that the UI will default to a more simpler version through a RemoteDesktop connection.
Upvotes: 0