Select to view content in your preferred language

custom maptip

931
5
03-10-2011 09:46 AM
SteveLi
Emerging Contributor
There is sample on maptip with custom content:

xaml:

<esri:GraphicsLayer>
  <esri:GraphicsLayer.MapTip>
    <StackPanel Orientation="Horizontal" Background="White">
      <TextBlock Text="Feature ID:" />
      <TextBlock Text="{Binding}" />
    </StackPanel>
  </esri:GraphicsLayer.MapTip>
<esri:GraphicsLayer>

My issue is I am adding my graphics layers dynamically in code.  How do I achieve the same in my code?

Thanks very much.
0 Kudos
5 Replies
IgressT
Emerging Contributor
There is sample on maptip with custom content:

xaml:

<esri:GraphicsLayer>
  <esri:GraphicsLayer.MapTip>
    <StackPanel Orientation="Horizontal" Background="White">
      <TextBlock Text="Feature ID:" />
      <TextBlock Text="{Binding}" />
    </StackPanel>
  </esri:GraphicsLayer.MapTip>
<esri:GraphicsLayer>

My issue is I am adding my graphics layers dynamically in code.  How do I achieve the same in my code?

Thanks very much.


this worked for me

http://forums.arcgis.com/threads/21098-How-to-create-MapTips-at-runtime?p=68890#post68890
0 Kudos
JenniferNery
Esri Regular Contributor
You can place any XAML-code in a UserControl and use it as your map tip.

For example, in MyMapTip.xaml
 <StackPanel Orientation="Horizontal">
  <TextBlock Text="ID: " />
  <TextBlock Text="{Binding [ObjectID]}" />
 </StackPanel>


You can then have the following code:
GraphicsLayer layer = new GraphicsLayer();
layer.MapTip = new MyMapTip();
MyMap.Layers.Add(layer);

Graphic graphic = new Graphic() 
{
 Geometry = new MapPoint(-140.9, 63.391),
 Symbol = this.LayoutRoot.Resources["RedMarkerSymbol"] as Symbol 
};
graphic.Attributes["ObjectID"] = 1234;
layer.Graphics.Add(graphic);
0 Kudos
SteveLi
Emerging Contributor
Thanks very much for all the answers.  I figured it out based on your solutions.
0 Kudos
MichaelLibio
Emerging Contributor
You can place any XAML-code in a UserControl and use it as your map tip. 

For example, in MyMapTip.xaml 
 <StackPanel Orientation="Horizontal">
  <TextBlock Text="ID: " />
  <TextBlock Text="{Binding [ObjectID]}" />
 </StackPanel>


You can then have the following code: 
GraphicsLayer layer = new GraphicsLayer();
layer.MapTip = new MyMapTip();
MyMap.Layers.Add(layer);

Graphic graphic = new Graphic() 
{
 Geometry = new MapPoint(-140.9, 63.391),
 Symbol = this.LayoutRoot.Resources["RedMarkerSymbol"] as Symbol 
};
graphic.Attributes["ObjectID"] = 1234;
layer.Graphics.Add(graphic);


I tried this and it works great, but I cannot use the GraphicsLayer.MapTipHideDelay attribute. Well, actually, I can use it; it just doesn't do what I want.
0 Kudos
MichaelLibio
Emerging Contributor
I tried this and it works great, but I cannot use the GraphicsLayer.MapTipHideDelay attribute.  Well, actually, I can use it; it just doesn't do what I want.


I figured it out...you need to set it at the UserControl element of the MapTipControl.xaml
0 Kudos