Have you heard about the new feature of iPhone 6S called 3D touch? It’s basically reinvented context menu on steroids that looks cool and can be useful in many cases, like providing quick context actions for apps on your home screen:
In this article I’ll show you, how to implement similar behavior in your Windows 10 UWP app using JumpList API.
First of all, this feature is not available in the Windows 10 RTM version. First you need to have the latest Windows 10 Insider preview build v10565 installed. Second you need to install the latest Windows beta SDK v10563 by following the guide here. Note you should not install this beta SDK on your production machine because you won’t be able to publish Store apps built with this SDK!
Once you have all this set up, it’s really straightforward, you just need to use the new JumpList API. This API allows you to place custom context menu items, that are shown when you right-click or tap-and-hold Tile of your Windows Store app.
Here’s a really simple code for adding those same Camera app context menu items to your Windows Store app:
JumpList jumpList = await JumpList.LoadCurrentAsync(); jumpList.Items.Clear(); JumpListItem item1 = JumpListItem.CreateWithArguments("selfie", "Take Selfie"); item1.Logo = new Uri("ms-appx:///Assets/selfie.png"); JumpListItem item2 = JumpListItem.CreateWithArguments("video", "Record Video"); item2.Logo = new Uri("ms-appx:///Assets/cam.png"); JumpListItem item3 = JumpListItem.CreateWithArguments("slomo", "Record Slo-mo"); item3.Logo = new Uri("ms-appx:///Assets/slomo.png"); JumpListItem item4 = JumpListItem.CreateWithArguments("photo", "Take Photo"); item4.Logo = new Uri("ms-appx:///Assets/cam.png"); jumpList.Items.Add(item1); jumpList.Items.Add(item2); jumpList.Items.Add(item3); jumpList.Items.Add(item4); await jumpList.SaveAsync();
Note that I’ve added four simple PNG images in Assets folder that are used for JumpListItems.
When you start your app and run this code, the context menu for your tile will look like this:
And if you click one of those Tasks, the app launches with the provided argument in the e.Argument property, so it’s really easy to open the right UI for the right task:
And that’s all 🙂
I think the JumpList API is a really nice addition to the UWP ecosystem. It could be used not just for displaying list of recently opened document or projects, but also for quick tasks similar to context menus on iPhone 6S.
Note the JumpList sample should work on Windows 10 Mobile too, if you have the latest build v10549. You can test it on a phone as your homework 🙂