1

I'm working on a UWP Windows 10 app in C#/Xaml, and I'm planning to extend use of its jump list.

So, I know how to handle custom Jump List tasks (such as new file, open file etc.), but for the files in its most recently used list, I've no idea at all as to how to intercept what file has been selected from the list (been unable to find any documentation for it, whereas for jump list tasks I was able to).

If I do pick a file when the app isn't open, the splash screen stays open. And if I pick one when the app is already open, it just puts focus back on the app (obviously the desired behaviour doesn't happen in this scenario because I'm not handling this event).

This would be easy to figure out, if there was a way for me to debug the app after I've launched it via a jump list file (or if there is an App event called when the app isn't in focus and I return focus to it by selecting a jump list file - maybe there is but I'm not aware of it).

Any guidance will be much appreciated!

4

1 回答 1

3

跳转列表激活

您将需要覆盖中的OnFileActivated事件App.xaml.cs。启动画面保持显示并且没有任何反应,因为在此事件处理程序中,您需要检查应用程序之前是否已启动,如果没有,您必须创建根框架并与OnLaunched处理程序类似地激活窗口。

OnFileActivated事件的签名是

void OnFileActivated(FileActivatedEventArgs args)

FileActivatedEventArgs包含属性,它是用于启动应用程序Files的文件列表 ( )。StorageFiles在文件激活和跳转列表激活的情况下,这将被适当地初始化。

未启动时调试应用程序

这是一个非常有用的提示 - 您可以开始调试并等待应用程序启动。只需在方法中设置断点OnFileActivated,转到解决方案资源管理器中的 UWP 应用项目属性,转到Debug选项卡并选中Do not launch, but debug my code when it starts

现在像往常一样开始调试,但应用程序不会启动,调试器将等到您手动启动它(例如使用跳转列表)并附加到它。

启动时调试

你可以用它来进行各种激活调试,所以记住它是一件非常好的事情。

于 2016-08-29T07:21:34.350 回答