Beispiel #1
0
        private static void BetterToolTip_MouseEnter(object sender, MouseEventArgs e)
        {
            FrameworkElement element = sender as FrameworkElement;

            if (element == null)
            {
                return;
            }

            Popup popup;

            if (_popUps.ContainsKey(element))
            {
                popup = _popUps[element];
            }
            else
            {
                popup                 = new Popup();
                popup.Margin          = new Thickness(0);
                popup.Child           = GetToolTip(element);
                popup.PlacementTarget = element;
                popup.Placement       = ToolTipService.GetPlacement(element);
                popup.StaysOpen       = true;
                _popUps.Add(element, popup);
            }

            popup.IsOpen = true;
        }
Beispiel #2
0
        //</SnippetToolTipClosingHandler>

        //</SnippetToolTipOpenAndCloseHandler>

        private void showProperties(object sender, RoutedEventArgs e)
        {
            ttProperties.ClearValue(TextBlock.TextProperty);
            ttPropertyValues.ClearValue(TextBlock.TextProperty);
            //<SnippetGetBetweenShowDelay>
            int myInt = ToolTipService.GetBetweenShowDelay(
                (DependencyObject)FindName("ellipse2"));

            //</SnippetGetBetweenShowDelay>
            AddTextString(ttProperties, ttPropertyValues, "BetweenShowDelay",
                          myInt.ToString());
            //<SnippetGetInitialShowDelay>
            myInt = ToolTipService.GetInitialShowDelay(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetInitialShowDelay>
            AddTextString(ttProperties, ttPropertyValues, "InitialShowDelay",
                          myInt.ToString());
            //<SnippetGetShowDuration>
            myInt = ToolTipService.GetShowDuration(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetShowDuration>
            AddTextString(ttProperties, ttPropertyValues, "ShowDuration",
                          myInt.ToString());
            //<SnippetGetHasDropShadow>
            bool myBool = ToolTipService.GetHasDropShadow(
                (DependencyObject)FindName("ellipse2"));

            //</SnippetGetHasDropShadow>
            AddTextString(ttProperties, ttPropertyValues, "HasDropShadow",
                          myBool.ToString());
            //<SnippetGetHorizontalOffset>
            double myDouble = ToolTipService.GetHorizontalOffset(
                (DependencyObject)FindName("ellipse2"));

            //</SnippetGetHorizontalOffset>
            AddTextString(ttProperties, ttPropertyValues, "HorizontalOffset",
                          myDouble.ToString());
            //<SnippetGetVerticalOffset>
            myDouble = ToolTipService.GetVerticalOffset(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetVerticalOffset>
            AddTextString(ttProperties, ttPropertyValues, "VerticalOffset",
                          myDouble.ToString());
            //<SnippetGetPlacement>
            PlacementMode myMode = ToolTipService.GetPlacement(
                (DependencyObject)FindName("ellipse2"));

            //</SnippetGetPlacement>
            AddTextString(ttProperties, ttPropertyValues, "Placement",
                          myMode.ToString());
            //<SnippetGetPlacementRectangle>
            Rect myRect = ToolTipService.GetPlacementRectangle(
                (DependencyObject)FindName("ellipse2"));

            //</SnippetGetPlacementRectangle>
            AddTextString(ttProperties, ttPropertyValues, "PlacementRectangle",
                          myRect.ToString());
            //<SnippetGetPlacementTarget>
            UIElement target = new UIElement();

            target = ToolTipService.GetPlacementTarget(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetPlacementTarget>
            if (target == null)
            {
                AddTextString(ttProperties, ttPropertyValues, "PlacementTarget",
                              "null");
            }
            else
            {
                AddTextString(ttProperties, ttPropertyValues, "PlacementTarget",
                              target.ToString());
            }
            //<SnippetGetIsDropShadow>
            myBool = ToolTipService.GetHasDropShadow(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetIsDropShadow>
            AddTextString(ttProperties, ttPropertyValues, "HasDropShadow",
                          myBool.ToString());
            //<SnippetGetIsEnabled>
            myBool = ToolTipService.GetIsEnabled(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetIsEnabled>
            AddTextString(ttProperties, ttPropertyValues, "IsEnabled",
                          myBool.ToString());
            //<SnippetGetIsOpen>
            myBool = ToolTipService.GetIsOpen(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetIsOpen>
            AddTextString(ttProperties, ttPropertyValues, "IsOpen",
                          myBool.ToString());
            //<SnippetGetShowOnDisabled>
            myBool = ToolTipService.GetShowOnDisabled(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetShowOnDisabled>
            AddTextString(ttProperties, ttPropertyValues, "ShowOnDisabled",
                          myBool.ToString());
            //<SnippetGetToolTip>
            target = (UIElement)ToolTipService.GetToolTip(
                (DependencyObject)FindName("ellipse2"));
            //</SnippetGetToolTip>
            AddTextString(ttProperties, ttPropertyValues, "ToolTip",
                          target.ToString());
        }