This is a migrated thread and some comments may be shown as answers.

Tooltip: open automatically and click event

1 Answer 964 Views
Map
This is a migrated thread and some comments may be shown as answers.
Massimiliano
Top achievements
Rank 1
Massimiliano asked on 13 Jul 2011, 09:23 PM
Hi all,
I have in a WPF form a RadMap control. Normally for show the tooltip information I have to click on every pushpin.
Is it possible to open automatically all the pushpin's tooltip?

Another question...
Is it possible to click inside the tooltip for open another form?

thanks in advance!!!

var pin = new Pushpin { Background = new SolidColorBrush(colore) };
var tip = new ToolTip { Content = tool };
ToolTipService.SetToolTip(pin, tip);
var loc = new Location { Latitude = lat, Longitude = lon };
MapLayer.SetLocation(pin, loc);
informationLayer.Items.Add(pin);

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 18 Jul 2011, 03:01 PM
Hi Massimiliano,

The tooltip has the predefined behavior of displaying when the mouse is over the element. You don't need to click the pushpin to make its tooltip appear. I think you can use the Pushpin.MouseEnter and Pushpin.MouseLeave events to show the pushpin's tooltip. I would also reccomend you to check that the pushpin is in the visible area so that the pushpin will be visible. This could be done using the InformationLayer.GetElementsInRectangle method.
The sample code is below:
// add pushpin
{
    var pin = new Pushpin { Background = new SolidColorBrush(colore) };
    var tip = new ToolTip { Content = tool };
    ToolTipService.SetToolTip(pin, tip);
 
    ToolTipService.SetInitialShowDelay(pin, 1000000);
 
    var loc = new Location { Latitude = lat, Longitude = lon };
    MapLayer.SetLocation(pin, loc);
 
    pin.MouseEnter += new MouseEventHandler(pin_MouseEnter);
    pin.MouseLeave += new MouseEventHandler(pin_MouseLeave);
 
    informationLayer.Items.Add(pin);
}
 
void pin_MouseEnter(object sender, MouseEventArgs e)
{
    this.ToggleToolTips(true);
}
 
void pin_MouseLeave(object sender, MouseEventArgs e)
{
    this.ToggleToolTips(false);
}
 
private void ToggleToolTips(bool isOpen)
{
    if (isOpen)
    {
        IEnumerable<object> objects = informationLayer.GetElementsInRectangle(radMap.LocationRect);
        foreach (object item in objects)
        {
            var pin = item as Pushpin;
            if (pin != null)
            {
                var toolTip = (ToolTip)pin.ToolTip;
                toolTip.PlacementTarget = pin;
                toolTip.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
                toolTip.IsOpen = isOpen;
            }
        }
    }
    else
    {
        foreach (object item in informationLayer.Items)
        {
            var pin = item as Pushpin;
            if (pin != null)
            {
                var toolTip = (ToolTip)pin.ToolTip;
                toolTip.IsOpen = isOpen;
            }
        }
    }
}


As another suggestion - you can handle the mouse left button down event to toggle visibility of the pushpin tooltip. You can use the same ToggleToolTips method functionality like the following:
void pin_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    e.Handled = true;
 
    var toolTip = (ToolTip)(sender as FrameworkElement).ToolTip;
    this.ToggleToolTips(!toolTip.IsOpen);
}

You can't click inside the tooltip to open another form. Probably you should use Popup instead of Tooltip, since Tooltip assumes that you're using it in the pre-defined UI-standards way.

Greetings,
Andrey Murzov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Map
Asked by
Massimiliano
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or