Exemplo n.º 1
0
        private void OnPreviewMouseLeftButtonDown()
        {
            var toolTip = ToolTipService.GetToolTip(this) as ToolTip;

            if (toolTip == null)
            {
                return;
            }

            var betweenShowDelay = ToolTipService.GetBetweenShowDelay(toolTip);
            var timeSpan         = DateTimeOffset.Now - _lastChangeTime;

            if (timeSpan.TotalMilliseconds < betweenShowDelay)
            {
                Debug.WriteLine("DateTimeOffset.Now - LastChangeTime < TimeSpan.FromMilliseconds(10)");
                return;
            }
            if (toolTip.IsOpen)
            {
                toolTip.IsOpen = false;
            }
            else
            {
                OpenToolTip();
            }
            Debug.WriteLine("Clicked: {0}, IsOpen: {1}", Name, toolTip.IsOpen);
        }
Exemplo n.º 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());
        }