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

How to change tooltip duration?

6 Answers 1281 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Wenjie
Top achievements
Rank 1
Wenjie asked on 10 Feb 2014, 08:58 AM
Hi All,

How to change tooltip duration? My code like this:
<DataTemplate x:Key="ToolTipTemplate">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <TextBlock Text="Subject: " />
            <TextBlock Text="{Binding Subject}" TextWrapping="Wrap"  FontWeight="Bold" />
        </StackPanel>
        <StackPanel Grid.Row="1" Orientation="Horizontal">
            <TextBlock Text="Body: " />
            <TextBlock Text="{Binding Body}" TextWrapping="Wrap" />
        </StackPanel>
        <StackPanel Grid.Row="2" Orientation="Horizontal">
            <TextBlock Text="Location: " />
            <TextBlock Text="{Binding Appointment.Resources[0].ResourceName}" />
        </StackPanel>
        <StackPanel Grid.Row="3" Margin="0 5 0 0">
            <StackPanel Orientation="Horizontal" Margin="0 0 0 0">
                <TextBlock Text="{Binding Start, StringFormat='hh:mm tt'}" TextWrapping="Wrap" FontSize="10" />
                <TextBlock Text=" - " FontSize="10" />
                <TextBlock Text="{Binding End, StringFormat='hh:mm tt'}" TextWrapping="Wrap" FontSize="10" />
            </StackPanel>
            <TextBlock Text="{Binding Start, StringFormat='dddd dd MMM yyyy'}" Margin="0 3" FontSize="10" />
        </StackPanel>
    </Grid>
</DataTemplate>
.....
<telerik:RadScheduleView ToolTipTemplate="{StaticResource ToolTipTemplate}" ... >
    ...
</telerik:RadScheduleView>

6 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 11 Feb 2014, 02:13 PM
Hello Wenjie,

In order to change the ToolTip duration you can use the approach explained in this forum post.

You can give it a try and let us know if you have any further questions.

Regards,
Kalin
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Andrew
Top achievements
Rank 1
answered on 24 Mar 2015, 01:55 AM
Is there a way to set the duration in the code behind such as when the tool tip's value is set?

Ideally, I would like the tool tip to stay open as long as the cursor is over the MapPolygon.  This is similar to this question (http://www.telerik.com/forums/tooltip-open-automatically-and-click-event) but that applies to a Pushpin, not a MapPolygon.  The MapPolygon's ToolTip does not have an IsOpen property.

I have a tooltip that has about 20 lines of information and this is essentially impossible to read in the time the tooltip is open.

Andrew
0
Martin Ivanov
Telerik team
answered on 24 Mar 2015, 02:24 PM
Hello Andrew,

I am afraid you cannot change the duration of the MapPolygon's tooltip. The MapPolygon is just a wrapper that describes the shape (a Polygon element in this case) which will be rendered on the map. The created visual element is not bound to the ToolTipService which leads to this limitation.

To achieve your requirement you can use several approaches:
  • Use data binding and set the tooltip and tooltip duration on the elements in the InformationLayer's ItemTemplate through the ToolTipService. 
  • Use FrameworkElements directly in the Items collection of the layer instead of MapShapes
  • Consider using the new VisualizationLayer and the map shape data objects. Basically, you can subscribe for the MapShapeVisualizationCreated event of the VisualizationLayer and inside its handler set a tooltip and its duration on the shape's visual element through the ToolTipService. Here is an example:
    private void visualizationLayer_MapShapeVisualizationCreated(object sender, MapShapeOperationEventArgs e)
    {
        var toolTip = e.Data.Location;
        ToolTipService.SetToolTip(e.Visualization, toolTip);
        ToolTipService.SetShowDuration(e.Visualization, 30000);
    }


Also, note that the map control provides two rendering engine packs - the old one consists of the the InformationLayer, VirtualizationLayer and DynamicaLayer. The new one is implemented through the VisualizationLayer which brings better performance, additional features and allows reading of shapes from different sources (KML, ESRI, and SQL Geospatial).

I hope this information helps.

Regards,
Martin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Andrew
Top achievements
Rank 1
answered on 24 Mar 2015, 11:25 PM
None of these options seems to work for me.

Using binding, I can set the ToolTip but not the Duration.  Both of the examples below do not work and I can't seem to find an element or attribute that would allow setting the duration.  Duration isn't an attribute of the ToolTip element either.
<ToolTipService.ToolTip>
   
<ToolTip Content="{Binding PropertiesAsText}"/>
    <Duration>30000</Duration>
</ToolTipService.ToolTip>

<ToolTipService.ToolTip>
   
<ToolTip Content="{Binding PropertiesAsText}"/>
    <ShowDuration>30000</ShowDuration>
</ToolTipService.ToolTip>

I'm not sure how using FrameworkElements would help since the layer is a collection of polygons (hence the use of MapPolygons).  Would I need to create my own class that inherits from FrameworkElements and write the drawing methods from scratch?

I am using the VisualizationLayer and MapPolygon objects but the Visualization layer doesn't seem to have a MapShapeVisualizationCreated event so the example you gave is never fired.  Both <telerik:VirtualizationLayer.MapShapeVisualizationCreated> and <telerik:VirtualizationLayer MapShapeVisualizationCreated="visualizationLayer_MapShapeVisualizationCreated"/> will not compile.

How can I tell if I'm using the "new" rendering engine pack or the "old' one?  We're using WPF_2014_1.

0
Andrew
Top achievements
Rank 1
answered on 25 Mar 2015, 12:02 AM
Sorry, I missed the VirtualizationLayer vs. VisualizationLayer.  I'm using VirtualizationLayer,  I see there are several articles on using the VisualizationLayer but before I go to the trouble of re-writing all my map related code, will this even help with the problem of the ToolTip that  I've been struggling with for a couple of days now?

If I make this change, can I control the ToolTip and make it stay open (open on mouse enter and close on mouse exit)?

One advantage I see is that creating the MapPolygons wasn't possible in the background process with the VirtualizationLayer (another few days wasted trying to get this to work) so I could eliminate the hacks I had to put into place to get this to work.  I'll look into making this switch but if you could help with the ToolTip problem that would be great.
0
Martin Ivanov
Telerik team
answered on 26 Mar 2015, 01:31 PM
Hi Andrew,

I attached a sample project demonstrating the map's VisualizationLayer populated with several polygon Framework and MapPolygonData elements. Each element have a tooltip that is displayed for some time - 1800000 milliseconds (30 minutes) in the attached example. This will ensure that the tooltip will be opened enough time so that it looks like it is always opened. About showing/hiding on mouse enter/leave, this behavior is built-int in the WPF's tooltip and you won't need to implement logic for this.

In addition I added a custom implementation that keeps open the tooltip even if the ShowDuration time is up. This logic is based on the approach used in the forum that you referenced to several replies back.

Please take a look at the project and let me know if it helps. Also, I would ask you to open a new forum (or a support ticket) in the corresponding section (RadMap in your case) if you have any questions that are not related to the current topic about the RadScheduleView.

Regards,
Martin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
ScheduleView
Asked by
Wenjie
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Andrew
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or