JumpList表现得很奇怪...... [英] JumpList behaves strange ...

查看:85
本文介绍了JumpList表现得很奇怪......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在WPF 4(.Net 4 BETA 2)中使用了新的JumpList-Class(在System.Windows.Shell中)并发现了一些奇怪的行为。当我执行以下代码时,第一个JumpTask运行良好,但JumpPath没有。 JumpList中显示了一个条目vshost.exe,而不是JumpPath。当我试图点击它时,没有任何反应。

另外,当我点击第二个JumpTask时,它应该启动当前应用程序。使用其他一些命令行args,我得到一个"未知错误"。

顺便说一句:有没有办法将一个JumpItem添加到一个众所周知的类别,比如最近?我没有找到方法。 BETA2-docu谈到 AddToRecentCategory方法 但我没有这样的方法。

我做错了什么?

问候,
曼弗雷德

ps:这是代码...


Hi,

I just played around with the new JumpList-Class (in System.Windows.Shell) in WPF 4 (.Net 4 BETA 2) and found some strange behaviour. When I execute the following code, the first JumpTask works well, but the JumpPath doesn't. Instead of the JumpPath there is an entry vshost.exe displayed in the JumpList. And when I try to click on it, nothing happens.

Additionally, when I click on the 2nd JumpTask, which should start the current app. with some other commandline args, I get an "unknown error".

Btw: Is there a way to add an JumpItem to an well-know category, like recent? I didn't find a method for that. The BETA2-docu talks about AddToRecentCategory Method but I do not have such a method.

What did I do wrong?

Regards,
Manfred

p.s.: Here's the code ...

                String readmePath = Path.Combine(Directory.GetCurrentDirectory(), "readme.txt");
                String self = Path.Combine(Directory.GetCurrentDirectory(), "Text.exe");
                
                JumpTask jumpTask1 = new JumpTask();
                jumpTask1.ApplicationPath = @"c:\windows\notepad.exe";
                jumpTask1.IconResourcePath = @"c:\windows\notepad.exe";
                jumpTask1.Title = "Notepad";
                jumpTask1.Description = "Notepad";
                jumpTask1.Arguments = @"c:\temp\test.txt";
                jumpTask1.CustomCategory = "SomeCategory";

                JumpTask jumpTask2 = new JumpTask();
                jumpTask2.ApplicationPath = self;
                jumpTask2.IconResourcePath = self;
                jumpTask2.Title = "Self";
                jumpTask2.Description = "Self";
                jumpTask2.Arguments = @"some other args";
                jumpTask2.CustomCategory = "SomeCategory";
            
                JumpPath jumpPath1 = new JumpPath();
                jumpPath1.Path = readmePath;
                jumpPath1.CustomCategory = "SomeCategory";

                JumpList jumpList = new JumpList();
                jumpList.JumpItems.Add(jumpTask1);
                jumpList.JumpItems.Add(jumpTask2);
                jumpList.JumpItems.Add(jumpPath1);
                
                jumpList.ShowFrequentCategory = true;
                jumpList.ShowRecentCategory = true;

                JumpList.SetJumpList(Application.Current, jumpList);

推荐答案

Hi Manfred,

我唯一安装的VS2010比Beta2更新,我在那里尝试了你的代码并且工作正常。尝试在VS之外独立运行您的应用程序,看看它是否表现不同。也许VS的调试器主机进程会以某种方式干扰。

对于第二个问题,要使用AddToRecentCategory,它是静态的,所以你需要有这样的代码:

JumpList.AddToRecentCategory (jumpTask)//或jumpPath或作为路径的字符串。

希望这有帮助,
Andre
Hi Manfred,

The only install of VS2010 I have available to me is newer than Beta2, and I tried your code there and it worked fine.  Try running your app stand-alone, outside of VS and see if it behaves differently.  Maybe VS's debugger host process is interfering somehow.

For the second question, To use AddToRecentCategory, it's static, so you need to have code something like this:

JumpList.AddToRecentCategory(jumpTask) // or jumpPath or a string that is a path.


Hope this helps,
Andre


这篇关于JumpList表现得很奇怪......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆