我在WPF应用程序中使用ProgressBar控件,但是它显示的是Windows 3.1风格的进度块。在VB6中,有一个属性可以显示平滑的ProgressBar。在WPF中是否有这样的属性?
我在WPF应用程序中使用ProgressBar控件,但是它显示的是Windows 3.1风格的进度块。在VB6中,有一个属性可以显示平滑的ProgressBar。在WPF中是否有这样的属性?
我没有找到直接的解决方案,但我发现了更好的方法。在WPF中,您可以使用Windows主题。我正在使用Windows XP,并在我的WPF应用程序中使用Vista-Aero主题,使所有控件看起来像Vista-Aero。
这是代码...
转到Application.xaml.vb并编写...
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
我希望您能将其转换为C#代码。
我不确定你想做什么。 如果你只是想要一个像启动Vista时从一侧到另一侧“扫过”的进度条,你可以使用:IsIndetermined = true。
如果你真的想从0%到100%,你必须要么像msdn上的这个例子中所示动画显示值http://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar.aspx,要么在代码后台(最可能是从后台工作者)显式设置值,或者通过绑定到一个变化的值来设置值。
尽管WPF ProgressBar应该始终是“平滑”的,但在远程桌面连接中,UI可能会默认为更简单的版本。
最近我在XP上开发时,对进度条的外观感到很烦恼,因为我是在Vista上进行开发的。我不想尝试从dll中加载Vista样式的建议,但this article给了我我想要的东西。它提供了Vista外观-没有新类。此外,它还有一个定时器上的玻璃高亮显示。文章中没有图片,但它看起来就像Vista的ProgressBar。