TaskbarItemInfo.ProgressState 屬性

定義

取得或設定值,這個值表示進度列指示器顯示在工作列按鈕中的方式。

public:
 property System::Windows::Shell::TaskbarItemProgressState ProgressState { System::Windows::Shell::TaskbarItemProgressState get(); void set(System::Windows::Shell::TaskbarItemProgressState value); };
public System.Windows.Shell.TaskbarItemProgressState ProgressState { get; set; }
member this.ProgressState : System.Windows.Shell.TaskbarItemProgressState with get, set
Public Property ProgressState As TaskbarItemProgressState

屬性值

列舉值,這個值表示進度列指示器顯示在工作列按鈕中的方式。 預設為 None

範例

下列範例示範如何利用程式碼設定 ProgressState 屬性。 狀態是在事件的處理常式 BackgroundWorker.RunWorkerCompleted 中設定,以指出背景工作是由使用者停止、以錯誤結束或正常完成。 這個範例是提供給 類別之較大範例的 TaskbarItemInfo 一部分。

void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    // When the task ends, change the ProgressState and Overlay
    // of the taskbar item to indicate a stopped task.
    if (e.Cancelled == true)
    {
        // The task was stopped by the user. Show the progress indicator
        // in the paused state.
        this.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.Paused;
    }
    else if (e.Error != null)
    {
        // The task ended with an error. Show the progress indicator
        // in the error state.
        this.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.Error;
    }
    else
    {
        // The task completed normally. Remove the progress indicator.
        this.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.None;
    }
    // In all cases, show the 'Stopped' overlay.
    this.taskBarItemInfo1.Overlay = (DrawingImage)this.FindResource("StopImage");
}
Private Sub bw_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
    ' When the task ends, change the ProgressState and Overlay
    ' of the taskbar item to indicate a stopped task.
    If e.Cancelled = True Then
        ' The task was stopped by the user. Show the progress indicator
        ' in the paused state.
        Me.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.Paused
    ElseIf e.Error IsNot Nothing Then
        ' The task ended with an error. Show the progress indicator
        ' in the error state.
        Me.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.Error
    Else
        ' The task completed normally. Remove the progress indicator.
        Me.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.None
        ' In all cases, show the 'Stopped' overlay.
        Me.taskBarItemInfo1.Overlay = Me.FindResource("StopImage")
    End If
End Sub

備註

您可以在 Windows 7 工作列按鈕中顯示進度指標,以傳達長時間執行工作的進度。 指標的色彩取決於 ProgressState 屬性,其中包含其中 TaskbarItemProgressState 一個列舉值。 ProgressState當 為 Normal 時,指標為綠色。 當 為 時 Paused ,指標為黃色。 當 為 時 Error ,指標為紅色。 針對這些狀態, ProgressValue 屬性會決定進度指標填滿了多少工作列按鈕。 ProgressValue 會忽略 的其他值 ProgressStateIndeterminate 會顯示整個工作列按鈕上的動動綠色指示器。 沒有針對 None 顯示指標。

下圖顯示處於 狀態的任務 Normal 欄進度指示器。

工作列專案資訊範例任務
Windows 工作列進度指示器

適用於