Users who love our app may appreciate a way to pin it to the system taskbar directly from the app UI. Universal Windows Platform has an API just for that and even better - it does work with the upcoming Windows 10X as well! To get access to the API, we first need to check for its presence.
TaskbarManager is available since Windows 10 version 16299, so if we want to support earlier versions as well, we should use
ApiInformation to verify first:
When we know
TaskbarManager is available, we can retrieve its instance using the
Some SKUs of Windows 10 don't have a taskbar (for example Xbox), so first need to verify that:
To avoid showing the dialog unnecessarily, we should first check if the application is already pinned:
Almost there, just one final check! The
TaskbarManager.IsPinningAllowed allows us to check if app pinning is allowed on the device, as organization can block it for work accounts using group policy (however weird a reason for that might be ?):
Now we can finally safely request to pin our app to the taskbar! We can call the asynchronous
RequestPinCurrentAppAsync method which returns a
bool value indicating if the user accepted the request and pinned the app:
The cool thing about this all is that it works on Windows 10X, too!
The example source code and sample app for this article is available here on my GitHub.
The taskbar was always one of the most important shell components in Windows. With tiles apparently going away in Windows 10X, it is worth adding the ability to pin our app to the taskbar to help users to open it quickly and easily.