表示作为菜单显示在 Windows 7 任务栏按钮上的项和任务的列表。
继承层次结构
System.Object
Microsoft.Windows.Shell.JumpList
命名空间: Microsoft.Windows.Shell
程序集: Microsoft.Windows.Shell(在 Microsoft.Windows.Shell.dll 中)
语法
声明
<ContentPropertyAttribute("JumpItems")> _
Public NotInheritable Class JumpList _
Implements ISupportInitialize
[ContentPropertyAttribute("JumpItems")]
public sealed class JumpList : ISupportInitialize
[ContentPropertyAttribute(L"JumpItems")]
public ref class JumpList sealed : ISupportInitialize
[<Sealed>]
[<ContentPropertyAttribute("JumpItems")>]
type JumpList =
class
interface ISupportInitialize
end
public final class JumpList implements ISupportInitialize
JumpList 类型公开以下成员。
构造函数
名称 | 说明 | |
---|---|---|
![]() |
JumpList() | 初始化 JumpList 类的新实例。 |
![]() |
JumpList(IEnumerable<JumpItem>, Boolean, Boolean) | 使用指定的参数初始化 JumpList 类的新实例。 |
页首
属性
名称 | 说明 | |
---|---|---|
![]() |
JumpItems | 获取在跳转列表中显示的 JumpItem 对象的集合。 |
![]() |
ShowFrequentCategory | 获取或设置一个值,该值指示常用项是否显示在跳转列表中。 |
![]() |
ShowRecentCategory | 获取或设置一个值,该值指示最近使用的项是否显示在跳转列表中。 |
页首
方法
名称 | 说明 | |
---|---|---|
![]() ![]() |
AddToRecentCategory(String) | 将指定的项路径添加到跳转列表的“最近”类别中。 |
![]() ![]() |
AddToRecentCategory(JumpPath) | 将指定的跳转路径添加到跳转列表的“最近”类别中。 |
![]() ![]() |
AddToRecentCategory(JumpTask) | 将指定的跳转任务添加到跳转列表的“最近”类别中。 |
![]() |
Apply | 在其当前状态下将 JumpList 发送到 Windows shell 中。 |
![]() |
BeginInit | 基础结构。用信号通知 JumpList 初始化开始。 |
![]() |
EndInit | 基础结构。用信号通知 JumpList 初始化结束。 |
![]() |
Equals | 确定指定的 Object 是否等于当前的 Object。 (继承自 Object。) |
![]() |
Finalize | 允许对象在“垃圾回收”回收之前尝试释放资源并执行其他清理操作。 (继承自 Object。) |
![]() |
GetHashCode | 用作特定类型的哈希函数。 (继承自 Object。) |
![]() ![]() |
GetJumpList | 返回与某个应用程序关联的 JumpList 对象。 |
![]() |
GetType | 获取当前实例的 Type。 (继承自 Object。) |
![]() |
MemberwiseClone | 创建当前 Object 的浅表副本。 (继承自 Object。) |
![]() ![]() |
SetJumpList | 设置与应用程序关联的 JumpList 对象。 |
![]() |
ToString | 返回表示当前对象的字符串。 (继承自 Object。) |
页首
事件
名称 | 说明 | |
---|---|---|
![]() |
JumpItemsRejected | 在 Windows shell 将跳转项添加到跳转列表中失败时发生。 |
![]() |
JumpItemsRemovedByUser | 在用户从跳转列表中移除以前位于该列表中的跳转项时发生。 |
页首
备注
Windows 7 任务栏为使用跳转列表直接从任务栏按钮启动程序提供了增强的功能。 跳转列表还用在 Windows 7 的“开始”菜单中。 可通过右键单击任务栏按钮或单击“开始”菜单中程序旁边的箭头访问跳转列表。有关跳转列表的更多信息,请参见 Windows 用户体验互动指南的 Taskbar(任务栏)部分。
JumpList 类为 Windows 7 任务栏中的跳转列表功能提供托管包装,并管理传递给 Windows shell 的数据。 JumpList 类公开的功能在 Windows 7 之前的 Windows 版本中不可用。 使用 JumpList 类的应用程序可以在其他版本的 Windows 中运行,但跳转列表将不可用。 有关 Windows shell 和本机跳转列表 API 的更多信息,请参见 Taskbar Extensions(任务栏扩展)。
下面的插图显示了 Windows 媒体播放器的跳转列表,带有**“任务”和“频率”**类别中的项。
Windows Media Player 跳转列表
配置跳转列表
跳转列表还可以包含两种类型的项:JumpTask 和 JumpPath。 JumpTask 是程序的链接,JumpPath 是文件的链接。 您可以通过创建一个未指定 Title 和 CustomCategory 的 JumpTask,来直观地分隔跳转列表中的项目。 此空的 JumpTask 将显示为跳转列表中的水平线。
![]() |
---|
如果在 JumpPath 中指定的文件类型没有向您的应用程序注册,文件将不显示在跳转列表中。例如,如果添加指向 .txt 文件的 JumpPath,则必须注册您的应用程序才能处理 .txt 文件。有关更多信息,请参见 Introduction to File Associations(文件关联简介)。 |
跳转项归入 JumpList 中的类别中。 默认情况下,JumpItem 显示在**“任务”**类别中。 或者,可以为 JumpItem 指定 CustomCategory。
您可以通过设置 ShowRecentCategory 和 ShowFrequentCategory 属性指定是否在 JumpList 中显示标准的**“最近”和“常用”类别。 这些类别的内容由 Windows shell 管理。 由于这些类别可能包含很多相同数据,因此通常在您的 JumpList 显示其中任一个,但不可两者兼有。 如果通过公用文件对话框打开最近的条目,或使用这些条目来通过文件类型关联打开应用程序,则 Windows 将自动管理这些条目。 当通过跳转列表访问某项时,您可以通过调用 AddToRecentCategory 方法通知 Windows shell 将该项添加到“最近”**类别中。
将跳转列表应用于 Windows Shell
您不能直接访问 shell 的跳转列表或将其内容读入 JumpList 类。 相反,JumpList 类提供您可以使用、然后应用于 Windows shell 的跳转列表的表示形式。 通常,您创建 JumpList 并在第一次运行应用程序时将其设置一次。 但是,您可以在运行时修改或替换 JumpList。
当您设置了 JumpList 属性后,必须将 JumpList 应用于 Windows shell,其内容才会出现在任务栏跳转列表中。 JumpList 首次附加到应用程序(以 XAML 形式或通过对 SetJumpList 方法的调用),这可自动实现。 如果在运行时修改 JumpList 内容,则必须调用 Apply 方法以将其当前内容应用于 Windows shell。
在 XAML 中设置跳转列表
JumpList 不自动附加到 Application 对象。 通过使用附加属性语法,可以将 JumpList 附加到 XAML 中的 Application 对象。 JumpList 类实现 ISupportInitialize 接口以支持 JumpList 的 XAML 声明。 如果 JumpList 是在 XAML 中声明的并附加到当前 Application,则它在初始化 JumpList 时自动应用于 Windows shell。
在代码中设置和修改跳转列表
通过调用静态 SetJumpList 方法,可以将 JumpList 附加到代码中的 Application 对象。 这还将 Windows 应用到 JumpList shell。
若要在运行时修改 JumpList,可调用 GetJumpList 方法来获取当前连接到 Application 的 JumpList。 在修改了 JumpList 的属性后,您必须调用 Apply 方法以将更改应用到 Windows shell。
![]() |
---|
通常,您会创建一个附加到 Application 并应用于 Windows shell 的 JumpList。但是,您可以创建多个 JumpList 对象。一次只能有一个 JumpList 应用于 Windows shell,且一次只能有一个 JumpList 可以与 Application 相关联。.NET Framework 不要求它们是相同的 JumpList。 |
![]() |
---|
此类在类级别上包含一个链接要求,该要求适用于所有成员。如果直接调用方不具有完全信任权限,则会引发 SecurityException。有关安全要求的更多信息,请参见链接需求和继承需求。 |
.NET Framework 安全性
-
表示完全访问权限以修改 Windows shell。 安全操作:LinkDemand。 关联枚举:UIPermissionWindow.AllWindows
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。