Ejemplo n.º 1
0
        /* Enable or Disable Description based on click Event
         * boolean value of tooltip enabler is obtained from tooltip service
         * Reverse the boolean value and set it back
         * tooltip opened or closed using isOpen
         * when tooltip is opened, tooltip placetarget is set to its button
         * it is done because content is not displayed for the first time is clicked
         */
        void OnClickDescription(object sender, RoutedEventArgs e)
        {
            Button  btn = sender as Button;
            ToolTip tt  = btn.ToolTip as ToolTip;

            bool CurrBool = ToolTipService.GetIsEnabled(btn);

            CurrBool = !CurrBool;
            ToolTipService.SetIsEnabled(btn, CurrBool);

            tt.IsOpen = CurrBool;


            if (CurrBool)
            {
                /*Works with tooltip datacontext in XAML file
                 * needed because the binding with description string is not invocked when button is pressed for the first time
                 */
                tt.PlacementTarget = btn;
            }
        }
Ejemplo 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());
        }