コード例 #1
0
        /// <summary>
        /// Unpins the item from the StartScreen and shows confirmation popup
        /// at the specified placement, relative to the sourceElement
        /// </summary>
        /// <param name="tileId"></param>
        /// <param name="shortName"></param>
        /// <param name="displayName"></param>
        /// <param name="logo"></param>
        /// <param name="sourceElement"></param>
        /// <param name="placement"></param>
        /// <returns></returns>
        public static async Task <bool> UnpinItem(string tileId, FrameworkElement sourceElement, Placement placement)
        {
            var tileToDelete = new SecondaryTile(tileId);

            bool unpinSuccess = await tileToDelete.RequestDeleteForSelectionAsync(VisualTreeHelperExtensions.GetElementRect(sourceElement), placement);

            return(unpinSuccess);
        }
コード例 #2
0
        private ContentControl GenerateHintItem(Hint hint)
        {
            var container = new ContentControl();

            var element = VisualTreeHelperExtensions.GetChildByName(Window.Current.Content as Control, hint.PlacementTargetName);
            Rect elementRect = VisualTreeHelperExtensions.GetElementRect(element);
            PlacementMode placement = hint.Placement;

            container.Width = hint.Width != 0 ? hint.Width : 50;
            container.Height = hint.Height != 0 ? hint.Height : 50;
            container.Content = hint.Content;

            double left = 0;
            double top = 0;
            Style style = null;

            switch (placement)
            {
                case PlacementMode.Bottom:
                    {
                        left = elementRect.Left + elementRect.Width / 2 - container.Width / 2;
                        top = elementRect.Top + elementRect.Height;
                        style = this.BottomHintStyle;
                    }
                    break;
                case PlacementMode.Top:
                    {
                        left = elementRect.Left + elementRect.Width / 2 - container.Width / 2;
                        top = elementRect.Top - container.Height;
                        style = this.TopHintStyle;
                    }
                    break;
                case PlacementMode.Left:
                    {
                        left = elementRect.Left - container.Width;
                        top = elementRect.Top + elementRect.Height / 2 - container.Height / 2;
                        style = this.LeftHintStyle;
                    }
                    break;
                case PlacementMode.Right:
                    {
                        left = elementRect.Left + elementRect.Width;
                        top = elementRect.Top + elementRect.Height / 2 - container.Height / 2;
                        style = this.RightHintStyle;
                    }
                    break;
            }

            container.Margin = new Thickness(left, top, 0, 0);
            container.SetValue(ToolTip.StyleProperty, style);

            return container;
        }
コード例 #3
0
        /// <summary>
        /// Pins the item to the StartScreen and shows confirmation popup
        /// at the specified placement, relative to the sourceElement
        /// </summary>
        /// <param name="tileId"></param>
        /// <param name="shortName"></param>
        /// <param name="displayName"></param>
        /// <param name="logo"></param>
        /// <param name="sourceElement"></param>
        /// <param name="placement"></param>
        /// <returns></returns>
        public static async Task <bool> PinItem(string tileId, string shortName, string displayName, Uri logo, FrameworkElement sourceElement, Placement placement)
        {
            string arguments = tileId;

            var newTile = new SecondaryTile(tileId, displayName, arguments, logo, TileSize.Square150x150);

            newTile.VisualElements.ForegroundText = ForegroundText.Dark;
            newTile.VisualElements.ShowNameOnSquare150x150Logo = true;

            bool pinSuccess = await newTile.RequestCreateForSelectionAsync(VisualTreeHelperExtensions.GetElementRect(sourceElement), placement);

            return(pinSuccess);
        }