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!

Barrrdi
  • 567
  • 7
  • 23

1 Answers1

3

Jump List activation

You will need to override the OnFileActivated event in App.xaml.cs. The Splash screen stays displayed and nothing happens because in this event handler, you need to check if the app has been previously launched or not and in case it was not, you have to create the root frame and activate the window similarly to the OnLaunched handler.

The signature of OnFileActivated event is

void OnFileActivated(FileActivatedEventArgs args)

FileActivatedEventArgs contains property Files, which is a list of files (StorageFiles) that were used to launch the app. In case of file activation and jump list activation, this is initialized appropriately.

Debugging app when not launched

This is a very useful tip - you can start debugging and wait until the app is launched. Just set the breakpoint in the OnFileActivated method, go to you UWP app project Properties in Solution Explorer, go to the Debug tab and check Do not launch, but debug my code when it starts.

Now start debugging as usual, but the app will not launch and the debugger will wait until you launch it manually (using the jump list for example) and will attach to it.

Debugging when launched

You can use this for all kinds of activation debugging, so it is a very good thing to remember.

Martin Zikmund
  • 34,962
  • 7
  • 63
  • 83