JumpLists 在 C# 应用程序中不起作用

发布于 2024-10-09 14:11:09 字数 1561 浏览 3 评论 0原文

我正在尝试在我的 C# 应用程序中使用“最近”和“频繁”跳转列表。我正在使用 Windows API Codepack v1.1 (http://code.msdn.microsoft.com/WindowsAPICodePack)。每次应用程序启动时,我都会初始化 JumpList,并且每次在应用程序中打开项目时,我都将 AddRecent() 添加到 JumpList。

缺少某些内容,因为当您右键单击任务栏中的应用程序图标时,跳转列表根本没有显示。我只显示了一个文件一次,但仅此而已!

初始化:

    private void InitializeJumpLists()
    {
        if (TaskbarManager.IsPlatformSupported)
        {
            JumpList recentJumpList = null;
            JumpList frequentJumpList = null;

            TaskbarManager.Instance.ApplicationId = Application.ProductName;

            recentJumpList = JumpList.CreateJumpList();
            recentJumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
            recentJumpList.Refresh();

            frequentJumpList = JumpList.CreateJumpList();
            frequentJumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Frequent;
            frequentJumpList.Refresh();
        }
    }

打开项目:

    private void OpenProject(string path, bool isFromRecentFilesList)
    {
        DialogResult result = ConfirmProjectClosing();

        if (result == DialogResult.Yes)
            Save();
        else if (result == DialogResult.Cancel)
            return;

        using (new Wait())
        {
            //Code here opens the project, etc.

            //Try to add the file to the Jump List.
            if (TaskbarManager.IsPlatformSupported)
                JumpList.AddToRecent(path);

            //Code here finished up.
        }
    }

我缺少什么?

I'm trying to use the Recent and Frequent JumpLists in my C# app. I'm using the Windows API Codepack v1.1 (http://code.msdn.microsoft.com/WindowsAPICodePack). I initialize the JumpLists every time the app starts and I AddRecent() to the JumpList every time I open a project in the app.

Something is missing becuase the JumpLists are simply not showing up when you right click the app's icon in the Taskbar. I got one file to show up once but that's it!

Initialization:

    private void InitializeJumpLists()
    {
        if (TaskbarManager.IsPlatformSupported)
        {
            JumpList recentJumpList = null;
            JumpList frequentJumpList = null;

            TaskbarManager.Instance.ApplicationId = Application.ProductName;

            recentJumpList = JumpList.CreateJumpList();
            recentJumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
            recentJumpList.Refresh();

            frequentJumpList = JumpList.CreateJumpList();
            frequentJumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Frequent;
            frequentJumpList.Refresh();
        }
    }

Opening the Project:

    private void OpenProject(string path, bool isFromRecentFilesList)
    {
        DialogResult result = ConfirmProjectClosing();

        if (result == DialogResult.Yes)
            Save();
        else if (result == DialogResult.Cancel)
            return;

        using (new Wait())
        {
            //Code here opens the project, etc.

            //Try to add the file to the Jump List.
            if (TaskbarManager.IsPlatformSupported)
                JumpList.AddToRecent(path);

            //Code here finished up.
        }
    }

What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

并安 2024-10-16 14:11:09

此页面上发生的情况与您遇到的问题密切相关吗?

Is what's happening at this page germane to the issue you're seeing?

因为看清所以看轻 2024-10-16 14:11:09

事实证明,这是 ClickOnce 部署的限制。使用正常的安装项目,安装后跳转列表按预期工作。

This turned out to be a limitation of ClickOnce deployments. Using a normal setup project, after installation the Jump Lists work as expected.

罪歌 2024-10-16 14:11:09

您是否已在应用程序中注册了文件扩展名? (我是我的案例中缺失的部分,无法让它发挥作用)

Have you registered the file extension with your application ? (I was the missing part in my case to get it work)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文