Пример #1
0
        private async void ShowLiveTileTipIfNeeded()
        {
            try
            {
                // You should  check if you've already shown this tip before,
                // and if so, don't show the tip to the user again.
                if (ApplicationData.Current.LocalSettings.Values.Any(i => i.Key.Equals("ShownLiveTileTip")))
                {
                    // But for purposes of this Quickstart, we'll always show the tip
                    //return;
                }

                // Store that you've shown this tip, so you don't show it again
                ApplicationData.Current.LocalSettings.Values["ShownLiveTileTip"] = true;

                // If Start screen manager API's aren't present
                if (!ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
                {
                    ShowMessage("StartScreenManager API isn't present on this build.");
                    return;
                }

                // Get your own app list entry (which is the first entry assuming you have a single-app package)
                var appListEntry = (await Package.Current.GetAppListEntriesAsync())[0];

                // Get the Start screen manager
                var startScreenManager = StartScreenManager.GetDefault();

                // Check if Start supports pinning your app
                bool supportsPin = startScreenManager.SupportsAppListEntry(appListEntry);

                // If Start doesn't support pinning, don't show the tip
                if (!supportsPin)
                {
                    ShowMessage("Start doesn't support pinning.");
                    return;
                }

                // Check if you're pinned
                bool isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(appListEntry);

                // If the tile is already pinned, don't show the tip
                if (isPinned)
                {
                    ShowMessage("The tile is already pinned to Start!");
                    return;
                }

                // Otherwise, show the tip
                FlyoutPinTileTip.ShowAt(ButtonShowTip);
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString());
            }
        }
Пример #2
0
        private async void ShowLiveTileTipIfNeeded()
        {
            try
            {
                //检查以前是否已经展示过这个技巧,
                //如果是这样,不要再向用户显示提示
                if (ApplicationData.Current.LocalSettings.Values.Any(i => i.Key.Equals("ShownLiveTileTile")))
                {
                    //始终展示
                }
                ApplicationData.Current.LocalSettings.Values["ShownLiveTileTip"] = true;
                //如果启动屏幕管理器API不存在
                if (!ApiInformation.IsTypePresent("Windows.UI.StartScreen.StartScreenManager"))
                {
                    ShowMessage("StartScreenManager API isn't present on this build.");
                    return;
                }
                //获取应用程序列表条目
                var appListEntry = (await Package.Current.GetAppListEntriesAsync())[0];
                //获取开始屏幕管理器
                var startScreenManager = StartScreenManager.GetDefault();
                //检查Start是否支持固定应用程序
                bool supportsPin = startScreenManager.SupportsAppListEntry(appListEntry);
                if (!supportsPin)
                {
                    ShowMessage("Start doesn't support pinning.");
                    return;
                }
                //固定
                bool isPinned = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(appListEntry);

                //如果已经固定上
                if (isPinned)
                {
                    ShowMessage("The tile is already pinned to Start!");
                    return;
                }

                // Otherwise, show the tip
                FlyoutPinTileTip.ShowAt(ButtonShowTip);
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString());
            }
        }