Training
Learning path
Use advance techniques in canvas apps to perform custom updates and optimization - Training
Use advance techniques in canvas apps to perform custom updates and optimization
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Now you can programmatically request users to pin your Win32 or UWP app to the taskbar, similar to how you can pin your app to the Start menu. And you can check whether your app is currently pinned, and whether the taskbar allows pinning.
Important
Requires Fall Creators Update: You must target SDK 16299 and be running build 16299 or later to use the taskbar APIs.
Important APIs: TaskbarManager class
The TaskbarManager class lets you ask the user to pin your app to the taskbar; the user must approve the request. You put a lot of effort into building a stellar app, and now you have the opportunity to ask the user to pin it to taskbar. But before we dive into the code, here are some things to keep in mind as you are designing your experience:
Important
The Taskbar Pinning is a Limited Access Feature (see LimitedAccessFeatures class). For more information or to request an unlock token, please use the LAF Access Token Request Form.
If your app supports older versions of Windows 10, you need to check whether the TaskbarManager
class is available. You can use the ApiInformation.IsTypePresent method to perform this check. If the TaskbarManager
class isn't available, avoid executing any calls to the APIs.
if (ApiInformation.IsTypePresent("Windows.UI.Shell.TaskbarManager"))
{
// Taskbar APIs exist!
}
else
{
// Older version of Windows, no taskbar APIs
}
If you want to use TaskbarManager
from your WIn32 desktop app, then you'll need to check whether desktop app support is present. You can look for the ITaskbarManagerDesktopAppSupportStatics
marker interface on the TaskbarManager
activation factory to perform this check. If this interface is not available, then you won't be able to use TaskbarManager
from your desktop app.
if (winrt::try_get_activation_factory<winrt::Windows::UI::Shell::TaskbarManager, winrt::Windows::UI::Shell::ITaskbarManagerDesktopAppSupportStatics>())
{
// TaskbarManager desktop app support is available.
}
else
{
// TaskbarManager desktop app support is not available.
}
Windows apps can run on a wide variety of devices; not all of them support the taskbar. Right now, only Desktop devices support the taskbar. Additionally, apps may request pinning, but pinning may not be allowed at any given time. It is suggested that apps check whether pinning is allowed before UX is surfaced to prevent confusing users.
Even if the taskbar is available, a group policy on the user's machine might disable taskbar pinning. So, before you attempt to pin your app, you need to check whether pinning to the taskbar is supported. The TaskbarManager.IsPinningAllowed property returns true
if the taskbar is present and allows pinning.
// Check if taskbar allows pinning, apps may request pinning, but pinning may not be allowed at any given time. It is suggested that apps check whether pinning is allowed before a UX is surfaced in order to prevent confusing users.
bool isPinningAllowed = TaskbarManager.GetDefault().IsPinningAllowed;
Important
There are also requirements that must be met at the time the call is actually made for the pin request to be allowed:
These requirements won't result in an exception if not met, the pin request will just be denied. IsPinningAllowed
can be called to determine if a pin request (prompt) will be allowed.
Note
If you don't want to pin your app to the taskbar and just want to find out whether the taskbar is available, use the TaskbarManager.IsSupported property.
Obviously, there's no point in asking the user to let you pin the app to the taskbar if it's already pinned there. You can use the TaskbarManager.IsCurrentAppPinnedAsync method to check whether the app is already pinned before asking the user.
// Check whether your app is currently pinned
bool isPinned = await TaskbarManager.GetDefault().IsCurrentAppPinnedAsync();
if (isPinned)
{
// The app is already pinned--no point in asking to pin it again!
}
else
{
//The app is not pinned.
}
If the taskbar is present and pinning is allowed and your app currently isn't pinned, you might want to show a subtle tip to let users know that they can pin your app. For example, you might show a pin icon somewhere in your UI that the user can click.
If the user clicks your pin suggestion UI, you would then call the TaskbarManager.RequestPinCurrentAppAsync method. This method displays a dialog that asks the user to confirm that they want your app pinned to the taskbar.
Important
This must be called from a foreground UI thread, otherwise an exception will be thrown.
// Request to be pinned to the taskbar.
bool isPinned = await TaskbarManager.GetDefault().RequestPinCurrentAppAsync();
This method returns a boolean value that indicates whether your app is now pinned to the taskbar. If your app was already pinned, the method immediately returns true
without showing the dialog to the user. If the user clicks "no" on the dialog, or pinning your app to the taskbar isn't allowed, the method returns false
. Otherwise, the user clicked yes and the app was pinned, and the API will return true
.
Windows developer feedback
Windows developer is an open source project. Select a link to provide feedback:
Training
Learning path
Use advance techniques in canvas apps to perform custom updates and optimization - Training
Use advance techniques in canvas apps to perform custom updates and optimization
Documentation
Taskbar pinning sample - Code Samples
Demonstrates how to pin an app or secondary tile to the taskbar
Badge notifications for Windows apps - Windows apps
Learn how to use badge notification to conveys summary or status information specific to your app.
Shell overview for Windows apps - Windows apps
Learn how to integrate your app with the Windows shell.