Please give me a sample of adding a custom tooltip to the XamWebMap MapLayer that would be attached to an .shp file and would have a TextBlock bound to a DataMapping item.
Hi flowerdj,
By default you could use Caption inside DataMapping:
<ig:MapLayer
Name="World" Brushes="#4C2C42C0 #4C218B93 #4CDC1C1C #4C3D7835 #4C701B51"
FillMode="Choropleth" WorldRect="{Binding ElementName=MainWindow, Path=WorldRect}"
>
<ig:MapLayer.Reader>
<ig:ShapeFileReader Uri="ShapeFiles\Cntry00\Cntry00"
DataMapping="Name=CNTRY_NAME; Value=POP_CNTRY; Caption=CNTRY_NAME; ToolTip=CNTRY_NAME" />
</ig:MapLayer.Reader>
<ig:MapLayer.ValueScale>
<ig:LinearScale IsAutoRange="True"/>
</ig:MapLayer.ValueScale>
</ig:MapLayer>
If you want a custom tooltip you need to create a DataTemplate inside ValueTemplate and attach a ToolTip to some of the elements in your DataTaplete.Here is an appropriate sample:
DataMapping="Name=CNTRY_NAME; Value=POP_CNTRY; Caption=CNTRY_NAME" />
<ig:MapLayer.ValueTemplate>
<DataTemplate>
<Border CornerRadius="4" BorderBrush="#00666666" BorderThickness="2" Background="#00cccccc" Padding="8">
<StackPanel>
<TextBlock FontSize="10" FontWeight="Bold" Text="{Binding Path=Name, StringFormat='Name: {0}'}" />
<ToolTipService.ToolTip>
<TextBlock FontSize="10" FontWeight="Bold" Text="{Binding Path=Value, StringFormat='Population: {0}'}" />
</StackPanel>
</Border>
</ToolTipService.ToolTip>
</DataTemplate>
</ig:MapLayer.ValueTemplate>
Hope this can help :-)
Cheers!
Mihail
This works for a tooltip for the TextBlock within the DataTemplate however, I was hoping to have a tooltip available for the whole element so that if I hovered over any part of it I would see the tooltip. Is there a way to do that?
Do you mean that you transfer your mouse to the tooltip and it doesn't stay open once your mouse leaves the underlying element? If you want to keep the overlayed content open while you interact with it you might need to use a programatically controlled popup instead and listen to the element hover/unhover events see my response here for some info in that regard: http://community.infragistics.com/forums/p/42136/233910.aspx#233910
I am not wanting to keep the tooltip open. I just want the tooltip to be available no matter where I am on the mapelement. With the current solution, the only time that I see the tooltip is when the first TextBlock is shown on the map and I hover directly over the TextBlock that is shown.
Hey,
I'm obviously having some trouble visualizing whats going on in your application. Is there a way you can provide a sample that demonstrates the problem you are having?
-Graham
I would have attached my shape file to this but the file attach that you have is limited to 200kB. You can pick up the schooldistrict shape file for Oregon from the Census (Tiger) site for shape files.
<
="HeatMap.MainPage"
="clr-namespace:Infragistics.Silverlight.Map;assembly=Infragistics.Silverlight.DataVisualization.Map.v9.2"
="LayoutRoot">
="10,20,0,0">
="SchoolDistricts">
="Name=NAME;District_ID=INST_ID;County_Name=CNTY"/>
="True"/>
="8">
="Vertical">
=Name}"/>
</
HI,
I am going to create a case for this issue and will reply to you via our CHS System.
Sincerely,
Matt Developer Support Engineer