Disable Tooltip Timeout on

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    8 posts
    Member since:
    Jul 2010

    Posted 04 Mar 2011 Link to this post

    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?
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 09 Mar 2011 Link to this post

    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!
  3. DevCraft banner
Back to Top