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

Disable Tooltip Timeout on

1 Answer 41 Views
Map
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 05 Mar 2011, 12:28 AM
I have an information layer with tooltips over shapes like so:

<telerik:InformationLayer.Reader>
                  <telerik:MapShapeReader Source="{Binding Source={StaticResource DataContext}, Path=StateShapefileSourceUri}"
                                          ReadCompleted="StateLayerReaderReadCompleted">
                      <telerik:MapShapeReader.ToolTipTemplate>
                          <DataTemplate>
                              <telerik:RadChart   
                                  Tag="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='STATE_NAME'}"                                   
                                  x:Name="drillDownChartState" Height="200" Width="350"  Loaded="drillDownChart_Loaded" >
                              </telerik:RadChart>
                          </DataTemplate>
                      </telerik:MapShapeReader.ToolTipTemplate>
                  </telerik:MapShapeReader>
              </telerik:InformationLayer.Reader>

I want to disable the tooltip timeout entirely, so tooltips are visible until the mouse leaves the shape -- they never disappear as the result of a timout. How do I do this?

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 09 Mar 2011, 10:43 AM
Hello Daniel,

You shouldn't use tooltip service if you want to show some additional content during unpredictable time. In this case you should show additional framework element on some user mouse input. For example, you can show content control when mouse enters to the map shape and remove it when mouse leave map shape:

<UserControl x:Class="ShowMapShapeTooltip.MainPage"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <telerik:ExtendedDataConverter x:Key="ExtendedDataConverter" />
  
        <DataTemplate x:Key="PopupTemplate">
            <Grid Background="White">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
  
                <TextBlock Grid.Column="0" Grid.Row="0" Text="Name:" />
                <TextBlock Grid.Column="1" Grid.Row="0"
                           Text="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='Name'}" />
  
                <TextBlock Grid.Column="0" Grid.Row="1" Text="Area:" />
                <TextBlock Grid.Column="1" Grid.Row="1"
                           Text="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='Area'}" />
            </Grid>
        </DataTemplate>
  
    </UserControl.Resources>
  
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadMap Name="radMap" 
                        ZoomLevel="7"
                        Center="36.5,-121.5">
            <telerik:RadMap.Provider>
                <telerik:OpenStreetMapProvider />
            </telerik:RadMap.Provider>
            <telerik:InformationLayer Name="informationLayer">
                <telerik:InformationLayer.Reader>
                    <telerik:MapShapeReader Source="{Binding Source={StaticResource DataContext}, Path=StateShapefileSourceUri}"
                        PreviewReadCompleted="StateLayerPreviewReadCompleted"
                        ReadCompleted="StateLayerReaderReadCompleted">
                    </telerik:MapShapeReader>
                </telerik:InformationLayer.Reader>
            </telerik:InformationLayer>
        </telerik:RadMap>
    </Grid>
</UserControl>

private void StateLayerPreviewReadCompleted(object sender, Telerik.Windows.Controls.Map.PreviewReadShapesCompletedEventArgs eventArgs)
{
    foreach (FrameworkElement item in eventArgs.Items)
    {
        MapShape shape = item as MapShape;
        if (shape != null)
        {
            shape.MouseEnter += new MouseEventHandler(this.ShapeMouseEnter);
            shape.MouseLeave += new MouseEventHandler(this.ShapeMouseLeave);
        }
    }
}
  
private void ShapeMouseEnter(object sender, MouseEventArgs e)
{
    MapShape shape = sender as MapShape;
    if (shape != null)
    {
        Location location = Location.GetCoordinates(this.radMap, e.GetPosition(this.radMap));
  
        ContentControl content = shape.Tag as ContentControl;
        if (shape.Tag == null)
        {
            content = new ContentControl();
            content.Content = shape.ExtendedData;
            content.ContentTemplate = this.Resources["PopupTemplate"] as DataTemplate;
            shape.Tag = content;
        }
        MapLayer.SetLocation(content, location);
  
        if (content != null)
        {
            this.informationLayer.Items.Add(content);
        }
    }
}
  
private void ShapeMouseLeave(object sender, MouseEventArgs e)
{
    MapShape shape = sender as MapShape;
    if (shape != null)
    {
        ContentControl content = shape.Tag as ContentControl;
        if (content != null)
        {
            this.informationLayer.Items.Remove(content);
        }
    }
}

Kind regards,
Andrey Murzov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Map
Asked by
Daniel
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or