need some feature

Topics: open request
Mar 5, 2010 at 7:35 AM

1.  Set Opacity of Tooltip

2. When parent of tooltip does not show tooltip will be hidden

Mar 5, 2010 at 3:42 PM
Hi,

could you elaborate a bit more on the features you are requesting?

You should be able to set the opacity on the ToolTip.
I use it in my sample where I do a fade-in and fade-out effect on the ToolTip, please take a look in the code.

The second one needs more explanation.
If the parent is not visible, there is no way to trigger the tooltip to show in the first place.

I'll investigate the behaviour of the last point you mention, but can you give me a scenario where you are running into issues currently?

Thanks!

Xavier

>----- Oorspronkelijk bericht -----
>Van
: binhlt [mailto:notifications@codeplex.com]
>Verzonden
: vrijdag
, maart
5, 2010 08:35 AM
>Aan
: xavier_decoster@telenet.be
>Onderwerp
: need some feature [tooltipservice:203907]
>
>From: binhlt
>
>1. Set Opacity of Tooltip2. When parent of tooltip does not show tooltip will be hidden
>
>
Mar 6, 2010 at 2:15 AM

sorry for my English

1. I add some code to make background to transparent. Affter that I can set Opacity of my tooltip but if you can modify your code to make it easy

public class ToolTip : System.Windows.Controls.ToolTip
{
        private const string _tt = "<ControlTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" +
                                   "                 xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"" +
                                   "                 >" +
                                   "    <Border CornerRadius=\"5\" >" +
                                   "        <ContentPresenter Content=\"{TemplateBinding Content}\"/>" +
                                   "    </Border>" +
                                   "</ControlTemplate>";

        public ToolTip()
        {
            ControlTemplate ct = (ControlTemplate)XamlReader.Load(_tt);
            base.Template = ct;
            ApplyTemplate();
        }

...

}

 

2. I have a control auto hidden after 1 minute with tooltip set to show 10 minute. Now i want when my control hidden (or dispose, ...) tooltip will be hidden

 

i add some code follow but i think it not perfect

....................

            ElementsAndTimers.Add(element, timer);
            ElementsAndToolTips.Add(element, toolTip);

            toolTip.PlacementTarget = (UIElement)element;
            toolTip.Opened += new RoutedEventHandler((s, e) =>
            {
                Storyboard sb = new Storyboard { Duration = new Duration(TimeSpan.FromSeconds(10)) };

                sb.Completed += (s1, e1) =>
                {
                    ToolTip tt = (s as ToolTip);
                    if (tt.PlacementTarget == null)
                    {
                        tt.IsOpen = false;
                        tt.Opacity = 1;
                    }
                    else
                    {
                        UIElement ui = tt.PlacementTarget;

                        if (!ui.RenderSize.Equals(new Size(0, 0)))
                        {
                            if (sb.Duration.TimeSpan.TotalSeconds > 1) sb.Duration = new Duration(TimeSpan.FromSeconds(1));
                            sb.Begin();
                        }
                        else
                        {
                            tt.IsOpen = false;
                            tt.Opacity = 1;
                        }
                    }
                };
                sb.Begin();
            });