任务栏中的进度条

任务栏中的进度条

本文介绍了将 WPF 中的 TaskBarItemInfo 用于 Win 7 任务栏中的进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Does anybody have a WPF example of updating the ProgressState through the available enum states when progressing through ProgressValue?

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

I have the following code which binds my progress value to run from 0 to 1:

<Window.TaskbarItemInfo>
    <TaskbarItemInfo Description="An app with a taskbar info description"
                     ProgressValue="{Binding Count}" ProgressState="Normal"/>
</Window.TaskbarItemInfo>

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

But, what is a good way to go from None to Normal to None or other flows: None-Normal-Paused-Normal-None.The code above shows the progress bar on the left at 0% and then finishes at 100% (1).I imagine I could bind this with a converter to another property hanging of my ViewModel, but wanted to see if anyone had any slicker solutions.

谢谢!

推荐答案

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

In the same way that you are binding the ProgressValue, you can also bind the ProgressState. The type of the ProgressState is an enum called TaskbarItemProgressState, which includes the states you already mentioned.

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,
}

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

I think the 'slickest' ways to do this are the ways you already mentioned, either with a converter or manually

这篇关于将 WPF 中的 TaskBarItemInfo 用于 Win 7 任务栏中的进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 23:35