C# WPF中的平滑进度条

C# WPF中的平滑进度条,c#,wpf,progress-bar,C#,Wpf,Progress Bar,我在WPF应用程序中使用ProgressBar控件,我得到了这个旧的Windows 3.1 ProgressBlocks。在VB6中,有一个显示平滑进度条的属性。WPF有这样的东西吗?KB文章似乎解释了您在寻找什么。。。这篇文章的VB版本也有一个链接。我不知道你想做什么。 如果您只是想要一个进度条,它可以像启动Vista一样从一边到另一边“扫描”,您可以使用:IsIndetermined=true 如果您确实希望从0%变为100%,则必须在值上设置动画,如msdn上的示例所示: 或者在代码隐藏中

我在WPF应用程序中使用ProgressBar控件,我得到了这个旧的Windows 3.1 ProgressBlocks。在VB6中,有一个显示平滑进度条的属性。WPF有这样的东西吗?

KB文章似乎解释了您在寻找什么。。。这篇文章的VB版本也有一个链接。

我不知道你想做什么。 如果您只是想要一个进度条,它可以像启动Vista一样从一边到另一边“扫描”,您可以使用:IsIndetermined=true

如果您确实希望从0%变为100%,则必须在值上设置动画,如msdn上的示例所示: 或者在代码隐藏中(很可能来自后台工作人员)或通过绑定到更改的值来显式设置值


尽管如此,WPF ProgressBar应该始终是“平滑的”,用户界面有可能通过远程桌面连接默认为更简单的版本。

我最近对在Vista上开发后在XP上出现的进度条感到恼火。我不想尝试我所看到的从dll中加载Vista样式的建议,但却给出了我想要的。vista外观-没有新类。加上计时器上有玻璃般的高光。文章中没有图片,但它看起来就像Vista的ProgressBar。

我无法找到直接的解决方案。但我发现了更好的东西。在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
Enum appThemes
航空的
卢娜
月牙
月球家园
皇家
结束枚举
私有子应用程序_Startup(ByVal sender作为对象,ByVal e作为System.Windows.StartupEventArgs)处理Me.Startup
setTheme(appThemes.Aero)
端接头
''' 
''函数设置此应用程序的默认主题
''' 
''' 
appThemes类型的“”主题
''' 
''' 
公共子集合主题(ByVal主题作为appThemes)
作为uri的Dim uri
选择案例主题
案例应用主题
'维斯塔航空主题
uri=新uri(“PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;组件\\主题/Aero.NormalColor.xaml”,UriKind.Relative)
露娜的案例
“月亮主题
uri=新uri(“PresentationFramework.Luna;V3.0.0.0;31bf3856ad364e35;组件\\主题/Luna.NormalColor.xaml”,UriKind.Relative)
露娜家园酒店
“月神
uri=新uri(“PresentationFramework.Luna;V3.0.0.0;31bf3856ad364e35;组件\\主题/Luna.Metallic.xaml”,UriKind.Relative)
月亮星座
“露娜家园
uri=新uri(“PresentationFramework.Luna;V3.0.0.0;31bf3856ad364e35;component\\themes/Luna.homestad.xaml”,UriKind.Relative)
皇家案件
皇家主题
uri=新uri(“PresentationFramework.Royale;V3.0.0.0;31bf3856ad364e35;组件\\主题/Royale.NormalColor.xaml”,UriKind.Relative)
结束选择
设定主题,
Resources.MergedDictionaries.Add(Application.LoadComponent(uri))
端接头

(我希望你能把它转换成C#)

不是答案,但关于进度条和平滑操作的主题,这里有一篇关于不同函数的好文章:哦。至少他说:“你不能再那样做了!”。可悲的是,这个解决方案本身有点过于简约——我严重怀疑它是否适用于动画。谢谢你,这是WinForms的解决方案。在WPF中,您应该为ProgressBar创建一个新的ControlTemplate。获取ProgressBarExamples.zip,在Window1.xaml中有一个styleProgressBarVista,您可以将其提取到您的xaml或ResourceDictionary中