使用WPF中的TaskBarItemInfo获取Win 7任务栏中的进度条

Sea*_*n B 8 wpf taskbar windows-7 progress-bar

有没有人在进行ProgressValue时有一个WPF示例通过可用的枚举状态更新ProgressState?

我有以下代码将我的进度值绑定为从0到1运行:

<Window.TaskbarItemInfo>
    <TaskbarItemInfo Description="An app with a taskbar info description" 
                     ProgressValue="{Binding Count}" ProgressState="Normal"/>
</Window.TaskbarItemInfo>
Run Code Online (Sandbox Code Playgroud)

但是,从None到Normal到None或其他流程的好方法是什么:None-Normal-Paused-Normal-None.上面的代码显示左侧的进度条为0%,然后以100%(1)结束.我想我可以将它与转换器绑定到我的ViewModel的另一个属性,但是想看看是否有人有任何更流畅的解决方案.

谢谢!

小智 8

与绑定 ProgressValue 的方式相同,您也可以绑定 ProgressState。ProgressState 的类型是一个名为 TaskbarItemProgressState 的枚举,其中包括您已经提到的状态。

public enum TaskbarItemProgressState
{
    // Summary:
    //     No progress indicator is displayed in the taskbar button.
    None = 0,
    //
    // Summary:
    //     A pulsing green indicator is displayed in the taskbar button.
    Indeterminate = 1,
    //
    // Summary:
    //     A green progress indicator is displayed in the taskbar button.
    Normal = 2,
    //
    // Summary:
    //     A red progress indicator is displayed in the taskbar button.
    Error = 3,
    //
    // Summary:
    //     A yellow progress indicator is displayed in the taskbar button.
    Paused = 4,
}
Run Code Online (Sandbox Code Playgroud)

我认为“最巧妙”的方法是您已经提到的方法,无论是使用转换器还是手动


小智 5

ProgressValue 是从 0 到 1 的双重使用值