Jumptlist in WPF and win7 explained

本文介绍Windows7中的一项新特性——任务栏跳转列表。通过.NET Framework 4.0提供的API,可以轻松地定制跳转列表中的项目,如最近打开的文件或自定义任务。示例展示了如何创建一个检查更新的任务,并在点击时显示消息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

THis article is based on the study of the page http://wpftutorial.net/Jumplists.html

 

and it demonstrate the use of a cool feature that is called Jumplist which is avaialbe in Windows 7.

 

 

here is the code 

 

Introduction

Windows 7 provides a new taskbar feature for applications called jumplists. They appear, when you right-click on a application icon in the taskbar. By default you see a list of recent files opened and two entries to launch and detach the application.

.NET 4.0 provides a managed API that allows you to easily manipulate the entries in the jumplist.

How to add a Task to the Jumplist

A jumplist is nothing more than a categorizes list of links to files that can be launched by the user. The links are calledJumpTasks. They can be parametrized with a title, description, icon, filepath and command line arguments.

In the following sample I create a new JumpList and add a task to the list that launches the sample application, but with a command line argument. If the application is launched with an argument, it shows a MessageBox instead.

 
public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
 
        if (e.Args.Count() > 0)
        {
            MessageBox.Show("You have the latest version.");
            Shutdown();
        }
 
        JumpTask task = new JumpTask
        {
            Title = "Check for Updates",
            Arguments = "/update",
            Description = "Cheks for Software Updates",
            CustomCategory = "Actions",
            IconResourcePath = Assembly.GetEntryAssembly().CodeBase,
            ApplicationPath = Assembly.GetEntryAssembly().CodeBase 
        };
 
        JumpList jumpList = new JumpList();
        jumpList.JumpItems.Add(task);
        jumpList.ShowFrequentCategory = false;
        jumpList.ShowRecentCategory = false;
 
        JumpList.SetJumpList(Application.Current, jumpList);
    }
}

 

 

 

With the above code, if you run the app, you will be able to see the following.

 

 

 

 

 

And if you click on the "CHeck for Updates", you will be able to see the MessageBox shown with the message "You have latest version"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值