JumpList クラス

定義

Windows 7 タスク バー ボタンにメニューとして表示される項目およびタスクの一覧を表します。

public ref class JumpList sealed : System::ComponentModel::ISupportInitialize
[System.Windows.Markup.ContentProperty("JumpItems")]
public sealed class JumpList : System.ComponentModel.ISupportInitialize
[System.Windows.Markup.ContentProperty("JumpItems")]
[System.Security.SecurityCritical]
public sealed class JumpList : System.ComponentModel.ISupportInitialize
[<System.Windows.Markup.ContentProperty("JumpItems")>]
type JumpList = class
    interface ISupportInitialize
[<System.Windows.Markup.ContentProperty("JumpItems")>]
[<System.Security.SecurityCritical>]
type JumpList = class
    interface ISupportInitialize
Public NotInheritable Class JumpList
Implements ISupportInitialize
継承
JumpList
属性
実装

次の例は、ジャンプ リストを持つアプリケーションを示しています。 アプリケーションには、現在のジャンプ リストにタスクを追加し、ジャンプ リストの内容をクリアし、新しいジャンプ リストをアプリケーションに適用できる 3 つのボタンがあります。

次の例は、マークアップで を宣言する方法を JumpList 示しています。 には JumpList 、2 つの JumpTask リンクと 1 つの JumpPathが含まれています。 JumpPath.txtファイル名拡張子を処理するためにアプリケーションが登録されていない場合、シェルに を適用すると失敗します。

<Application x:Class="JumpListSample.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <JumpList.JumpList>
        <JumpList ShowRecentCategory="True"
                  ShowFrequentCategory="True"
                  JumpItemsRejected="JumpList_JumpItemsRejected"
                  JumpItemsRemovedByUser="JumpList_JumpItemsRemovedByUser">
            <JumpTask Title="Notepad" 
                      Description="Open Notepad." 
                      ApplicationPath="C:\Windows\notepad.exe"
                      IconResourcePath="C:\Windows\notepad.exe"/>
            <JumpTask Title="Read Me" 
                      Description="Open readme.txt in Notepad." 
                      ApplicationPath="C:\Windows\notepad.exe"
                      IconResourcePath="C:\Windows\System32\imageres.dll"
                      IconResourceIndex="14"
                      WorkingDirectory="C:\Users\Public\Documents"
                      Arguments="readme.txt"/>
            <JumpPath Path="C:\Users\Public\Documents\readme.txt" />
        </JumpList>
    </JumpList.JumpList>
</Application>

次の例は、 の分離コード ページを App.xaml示しています。 このコードは、 イベントと JumpItemsRemovedByUser イベントをJumpItemsRejected処理します。

using System.Text;
using System.Windows;
using System.Windows.Shell;

namespace JumpListSample
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private void JumpList_JumpItemsRejected(object sender, System.Windows.Shell.JumpItemsRejectedEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("{0} Jump Items Rejected:\n", e.RejectionReasons.Count);
            for (int i = 0; i < e.RejectionReasons.Count; ++i)
            {
                if (e.RejectedItems[i].GetType() == typeof(JumpPath))
                    sb.AppendFormat("Reason: {0}\tItem: {1}\n", e.RejectionReasons[i], ((JumpPath)e.RejectedItems[i]).Path);
                else
                    sb.AppendFormat("Reason: {0}\tItem: {1}\n", e.RejectionReasons[i], ((JumpTask)e.RejectedItems[i]).ApplicationPath);
            }

            MessageBox.Show(sb.ToString());
        }

        private void JumpList_JumpItemsRemovedByUser(object sender, System.Windows.Shell.JumpItemsRemovedEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("{0} Jump Items Removed by the user:\n", e.RemovedItems.Count);
            for (int i = 0; i < e.RemovedItems.Count; ++i)
            {
                sb.AppendFormat("{0}\n", e.RemovedItems[i]);
            }

            MessageBox.Show(sb.ToString());
        }
    }
}

次の例は、アプリケーション ユーザー インターフェイスの作成に使用されるマークアップを示しています。

<Window x:Class="JumpListSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Jump List Sample" Height="240" Width="500">
    <Window.Resources>
        <Style TargetType="Button">
            <Setter Property="Width" Value="200" />
            <Setter Property="Margin" Value="5" />
        </Style>
    </Window.Resources>
    <Grid>
        <StackPanel>
            <Button Content="Add Task to JumpList" Click="AddTask" />
            <Button Content="Clear Jump List" Click="ClearJumpList"/>
            <Button Content="Set New Jump List" Click="SetNewJumpList" />
        </StackPanel>
    </Grid>
</Window>

次の例は、 の分離コード ページを MainWindow.xaml示しています。 このコードでは、手続き型コードで を変更、クリア、および作成する JumpList 方法を示します。 新しいジャンプ リストでは、静的 SetJumpList メソッドが呼び出され、 JumpList が現在のアプリケーションに関連付け、Windows シェルに 適用 JumpList されます。

using System;
using System.IO;
using System.Windows;
using System.Windows.Shell;

namespace JumpListSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void AddTask(object sender, RoutedEventArgs e)
        {
            // Configure a new JumpTask.
            JumpTask jumpTask1 = new JumpTask();
            // Get the path to Calculator and set the JumpTask properties.
            jumpTask1.ApplicationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.SystemX86), "calc.exe");
            jumpTask1.IconResourcePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.SystemX86), "calc.exe");
            jumpTask1.Title = "Calculator";
            jumpTask1.Description = "Open Calculator.";
            jumpTask1.CustomCategory = "User Added Tasks";
            // Get the JumpList from the application and update it.
            JumpList jumpList1 = JumpList.GetJumpList(App.Current);
            jumpList1.JumpItems.Add(jumpTask1);
            JumpList.AddToRecentCategory(jumpTask1);
            jumpList1.Apply();
        }
        private void ClearJumpList(object sender, RoutedEventArgs e)
        {
            JumpList jumpList1 = JumpList.GetJumpList(App.Current);
            jumpList1.JumpItems.Clear();
            jumpList1.Apply();
        }
        private void SetNewJumpList(object sender, RoutedEventArgs e)
        {
            //Configure a new JumpTask
            JumpTask jumpTask1 = new JumpTask();
            // Get the path to WordPad and set the JumpTask properties.
            jumpTask1.ApplicationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "write.exe");
            jumpTask1.IconResourcePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "write.exe");
            jumpTask1.Title = "WordPad";
            jumpTask1.Description = "Open WordPad.";
            jumpTask1.CustomCategory = "Jump List 2";
            // Create and set the new JumpList.
            JumpList jumpList2 = new JumpList();
            jumpList2.JumpItems.Add(jumpTask1);
            JumpList.SetJumpList(App.Current, jumpList2);
        }
    }
}

注釈

Windows 7 タスク バーには、ジャンプ リストを使用してタスク バー ボタンから直接プログラムを開始するための機能が強化されています。 ジャンプ リストは、Windows 7 の [スタート] メニューでも使用されます。 ジャンプ リストにアクセスするには、タスク バー ボタンを右クリックするか、[スタート] メニューのプログラムの横にある矢印をクリックします。 ジャンプ リストの詳細については、「Windows ユーザー エクスペリエンスの操作ガイドライン」の 「タスク バー 」セクションを参照してください。

クラスは JumpList 、Windows 7 タスク バーのジャンプ リスト機能のマネージド ラッパーを提供し、Windows シェルに渡されるデータを管理します。 クラスによって JumpList 公開される機能は、Windows 7 より前のバージョンの Windows では使用できません。 クラスを JumpList 使用するアプリケーションは、他のバージョンの Windows で実行されますが、ジャンプ リストは使用できません。 Windows シェルとネイティブジャンプ リスト API の詳細については、「 タスク バー拡張機能」を参照してください。

次の図は、[タスク] カテゴリと [頻繁] カテゴリの項目を含む、Windows メディア プレーヤーのジャンプ リストを示しています。

ジャンプ リストのWindows メディア プレーヤー
Windows メディア プレーヤーのジャンプ リスト

ジャンプ リストの構成

ジャンプ リストには、 と の 2 種類の項目をJumpTaskJumpPath含めることができます。 は JumpTask プログラムへのリンクであり、 JumpPath はファイルへのリンクです。 と が指定されていない を作成JumpTaskすることで、ジャンプ リスト内の項目を視覚的にTitleCustomCategory分離できます。 この空 JumpTask は、ジャンプ リストに水平線として表示されます。

注意

JumpPath 指定されたファイルの種類がアプリケーションに登録されていない場合、ファイルはジャンプ リストに表示されません。 たとえば、.txt ファイルを指す を追加 JumpPath する場合は、.txt ファイルを処理するためにアプリケーションを登録する必要があります。 詳細については、「 ファイルの関連付けの概要」を参照してください。

ジャンプ項目は、 のカテゴリに配置されます JumpList。 既定では、 JumpItem[タスク] カテゴリに表示されます。 または、 に をJumpItem指定CustomCategoryすることもできます。

標準の Recent カテゴリと Frequent カテゴリを にJumpList表示するかどうかを指定するには、 プロパティと ShowFrequentCategory プロパティをShowRecentCategory設定します。 これらのカテゴリの内容は、Windows シェルによって管理されます。 これらのカテゴリには同じデータの多くが含まれている可能性があるため、通常、どちらか一方を に JumpList表示しますが、両方は表示しません。 Windows は、共通のファイル ダイアログ ボックスで開かれた場合、またはファイルの種類の関連付けを使用してアプリケーションを開くために使用される場合、最近使用した項目を自動的に管理します。 ジャンプ リストを介してアイテムにアクセスする場合は、 メソッドを呼び出して、アイテムを Recent カテゴリに追加するように Windows シェルに AddToRecentCategory 通知できます。

Windows シェルへのジャンプ リストの適用

シェルのジャンプ リストに直接アクセスしたり、その内容を クラスに JumpList 読み込んだりすることはできません。 代わりに、 クラスは JumpList 、操作できるジャンプ リストの表現を提供し、Windows シェルに適用します。 通常は、 を JumpList 作成し、アプリケーションの初回実行時に 1 回設定します。 ただし、実行時に を JumpList 変更または置き換えることができます。

プロパティを設定したら、タスク バーの JumpList ジャンプ リストにコンテンツが表示される前に、 を Windows シェルに適用 JumpList する必要があります。 これは、 が XAML または メソッドの呼び出しでアプリケーションに最初にアタッチされるときに JumpList 自動的に SetJumpList 行われます。 実行時に の JumpList 内容を変更する場合は、 メソッドを Apply 呼び出して、その現在の内容を Windows シェルに適用する必要があります。

XAML でのジャンプ リストの設定

JumpListはオブジェクトに自動的にApplicationアタッチされません。 JumpList添付プロパティの構文をApplication使用して、XAML の オブジェクトに をアタッチします。 クラスは JumpList 、 の ISupportInitialize XAML 宣言をサポートする インターフェイスを JumpList実装します。 JumpListが XAML で宣言され、現在Applicationの にアタッチされている場合、 が初期化されると、自動的に Windows シェルにJumpList適用されます。

コードでのジャンプ リストの設定と変更

静的SetJumpListメソッドをJumpListApplication呼び出して、コード内の オブジェクトに をアタッチします。 これは、 を JumpList Windows シェルにも適用します。

実行時に を JumpList 変更するには、 メソッドを GetJumpList 呼び出して、 JumpList に現在アタッチされている を Application取得します。 の JumpListプロパティを変更したら、 メソッドを Apply 呼び出して、Windows シェルに変更を適用する必要があります。

注意

通常は、 にアタッチされ、Windows シェルにApplication適用される を作成JumpListします。 ただし、複数の JumpList オブジェクトを作成できます。 Windows シェルに適用できるのは一度に 1 JumpList つだけであり、 に関連付けることができるのは一度に Application1 つだけJumpListです。 .NET Frameworkでは、これらが同じ JumpListである必要はありません。

注意

このクラスには、すべてのメンバーに適用されるクラス レベルでのリンク要求が含まれています。 SecurityExceptionは、直接の呼び出し元に完全信頼アクセス許可がない場合にスローされます。 セキュリティ要求の詳細については、「 リンク要求継承要求」を参照してください。

コンストラクター

JumpList()

JumpList クラスの新しいインスタンスを初期化します。

JumpList(IEnumerable<JumpItem>, Boolean, Boolean)

指定したパラメーターを使用して、JumpList クラスの新しいインスタンスを初期化します。

プロパティ

JumpItems

ジャンプ リスト内に表示される JumpItem オブジェクトのコレクションを取得します。

ShowFrequentCategory

頻繁に使用される項目をジャンプ リストに表示するかどうかを示す値を取得または設定します。

ShowRecentCategory

最近使用された項目をジャンプ リストに表示するかどうかを示す値を取得または設定します。

メソッド

AddToRecentCategory(JumpPath)

指定したジャンプ パスをジャンプ リストの [最近 ] カテゴリに追加します。

AddToRecentCategory(JumpTask)

指定したジャンプ タスクをジャンプ リストの [最近 ] カテゴリに追加します。

AddToRecentCategory(String)

指定した項目パスをジャンプ リストの Recent カテゴリに追加します。

Apply()

現在の状態の JumpList を Windows シェルに送信します。

BeginInit()

JumpList の初期化の開始を通知します。

EndInit()

JumpList の初期化の終了を通知します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetJumpList(Application)

アプリケーションに関連付けられている JumpList オブジェクトを返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
SetJumpList(Application, JumpList)

アプリケーションに関連付けられている JumpList オブジェクトを設定します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

イベント

JumpItemsRejected

Windows シェルによってジャンプ リスト項目がジャンプ リストに正常に追加されない場合に発生します。

JumpItemsRemovedByUser

以前からジャンプ リストにあったジャンプ項目がユーザーによってリストから削除された場合に発生します。

適用対象