Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the TaskBarItemInfo in WPF for the progress bar in Win 7 taskbar

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

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>

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.

Thanks!

like image 599
Sean B Avatar asked Apr 20 '11 21:04

Sean B


People also ask

How use progress bar in WPF application?

Let's create a new WPF project with the name WPFProgressBarControl. The following example shows how to use the ProgressBar control. Here is the XAML code in which two ProgressBar controls are created and initialized.

How use progress bar in WPF for long running tasks?

Long running tasks in any application make the application or software nonresponsive. So to keep the user updated about the running task and also keep the application responsive during long running tasks we can use different kinds of loading bar options like. Ring Bar etc.


2 Answers

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

like image 200
Tim W Avatar answered Oct 15 '22 09:10

Tim W


ProgressValue is double use value from 0 to 1

like image 20
Vitaliy Avatar answered Oct 15 '22 09:10

Vitaliy