JumpListItem 類別

定義

提供為應用程式跳躍清單建立和定義跳躍清單專案的功能。

public ref class JumpListItem sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 131072)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class JumpListItem final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 131072)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class JumpListItem
Public NotInheritable Class JumpListItem
繼承
Object Platform::Object IInspectable JumpListItem
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10586.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v2.0 引進)

範例

下列範例示範如何為 JumpList 建立工作,以使用命令列參數啟動應用程式,並採取所需的動作。 不會顯示當地語系化,但可透過使用ms-resource:ms-appx:URI 配置,來顯示 DisplayNamedescriptionlogo

private Windows.UI.StartScreen.JumpListItem CreateJumpListItemTask()
{
    var taskItem = JumpListItem.CreateWithArguments(
                            "/Argument", "DisplayName");

    // Set the description. (Optional.)
    taskItem.Description = "Compose a new message to " + friendName;

    // Set the logo for this jump list item. Must be ms-appx: or ms-appdata:.
    taskItem.Logo = new Uri("ms-appdata:///local/downloads/taskImage.png");

    // If the GroupName is left blank, then the item goes into the Tasks group by default.

    return taskItem;
}

partial class App
{
    protected override void OnLaunched(LaunchActivatedEventArgs e)
    {
        if (e.Kind == ActivationKind.Launch && e.Arguments == "/Argument")
        {
            // Run code relevant to the task that was selected.
        }
    }
}

備註

JumpListItem 是使用 CreateWithArgumentsCreateSeparator 方法建立的。 建立之後,可以使用跳躍清單的 Items 屬性和 SaveAsync 方法,將其新增至應用程式的跳躍清單。 請注意,在使用者介面中,使用者可以以滑鼠右鍵按一下自訂群組中的跳躍清單專案,然後選取 [從此清單移除]。 發生此動作時,系統會將專案標示為使用者移除,並從 UI 隱藏該專案。 下次應用程式載入跳躍清單時,應該檢查項目,以查看專案的 RemovedByUser 屬性是否設定為 True。 如果 RemovedByUser 為 True,則應用程式應該更新其內部狀態,以與使用者起始的變更同步。 應用程式必須負責確保移除的專案不會新增回跳躍清單,直到符合新增條件等時間,例如,使用者再次開啟相關聯的檔。

當應用程式使用SaveAsync儲存JumpList時,作業系統會組織專案,如下所示。

  • 已移除所有 RemovedByUser 等於 True 的專案。
  • 具有相同 GroupName 屬性的專案會放在一起,並保留其相對順序。
  • 群組會依群組中第一個專案的原始位置排序,但例外狀況是系統管理群組一律位於頂端,如果工作群組存在,則工作群組一律位於底部。 這表示當應用程式使用LoadCurrentAsync方法載入其 JumpList時,會依其組織順序擷取專案,這可能不會同意最初儲存時跳躍清單中的專案順序。

屬性

Arguments

取得跳躍清單專案的命令列引數。

Description

取得或設定跳躍清單專案工作描述。

DisplayName

取得或設定跳躍清單專案顯示名稱。 建立跳躍清單專案時,也可以使用 CreateWithArguments 方法,將顯示名稱指定為參數。

GroupName

取得或設定跳躍清單專案自訂群組名。 如果未指定任何名稱,預設會將專案新增至 [工作] 群組。

Kind

取得跳躍清單專案的 JumpListItemKind

Logo

取得或設定跳躍清單專案的標誌。

RemovedByUser

取得布林值,指出使用者是否已從應用程式的跳躍清單中移除跳躍清單專案。

方法

CreateSeparator()

建立跳躍清單專案,此專案是應用程式跳躍清單內自訂群組的插入分隔符號。

CreateWithArguments(String, String)

為應用程式的跳躍清單建立新的跳躍清單專案。

適用於

另請參閱