Follow the previous section to continue the study, this section is mainly the use of elementlayer implementation of the mouse hover out of the definition form
Reference post: http://www.cnblogs.com/luxiaoxun/p/3322218.html
One, new Silverlight user control
Custom forms, you can place many controls, named Mymaptip.xaml, with the following code:
<grid x:name= "LayoutRoot" width= "the" height= "" background= "Transparent" >
<border cornerradius= "5" >
<Border.Background>
<solidcolorbrush color= "Black" opacity= "0.5"/>
</Border.Background>
<stackpanel margin= "5" >
<textblock foreground= "Wheat" textwrapping= "Wrap" name= "Textheadline" ></TextBlock>
<textblock foreground= "Wheat" textwrapping= "Wrap" name= "texteffective" ></TextBlock>
<textblock foreground= "Wheat" textwrapping= "Wrap" name= "Textdescription" ></TextBlock>
</StackPanel>
</Border>
</Grid>
The background code is:
Public Mymaptip (string effective, string headline, String DESCRIPTION)
{
InitializeComponent ();
Texteffective.text = "Release time:" + effective;
Textheadline.text = "title:" + headline;
Textdescription.text = DESCRIPTION;
}
Second, implement the custom form popup
1. Define Global variables: elementlayer elementlayer = new ESRI. ArcGIS.Client.ElementLayer ();
2, load Elementlayer in the map (preferably placed after loading graphicslayer, layer loading order: After loading in the upper layer):
THIS.MYMAP.LAYERS.ADD (Elementlayer);
3. Add properties for graphic and increase mouse events for Graphicslayer
private void Addlightmarker ()
{
Graphicslayer Glayer = new ESRI. ArcGIS.Client.GraphicsLayer ();
Graphic g = new Graphic ()
{
Geometry = Mercator. Fromgeographic (New MapPoint (108.2, 37.1)),
Symbol = layoutroot.resources["Strobemarkersymbol"] as Symbol
};
G.attributes.add ("Effective", "helllo!");
G.attributes.add ("headline", "FDAFADFAF");
G.attributes.add ("DESCRIPTION", "BADFADFAFAF");
Glayer. Graphics.add (g);
THIS.MYMAP.LAYERS.ADD (Glayer);
Mouse Hover Events
Glayer. MouseEnter + = Glayer_mouseenter;
Mouse Move Event
Glayer. MouseLeave + = Glayer_mouseleave;
}
4. Handling mouse events, displaying custom forms
void Glayer_mouseleave (object sender, ESRI. ArcGIS.Client.GraphicMouseEventArgs e)
{
ElementLayer.Children.Clear ();
throw new System.NotImplementedException ();
}
void Glayer_mouseenter (object sender, ESRI. ArcGIS.Client.GraphicMouseEventArgs e)
{
Graphic g = e.graphic;
ElementLayer.Children.Clear (); Clear the previous display screen
Mymaptip Infowindow = new Mymaptip (g.attributes["effective"]. ToString (), g.attributes["headline"]. ToString (), g.attributes["DESCRIPTION"]. ToString ()); Instantiate an interface
Projected coordinate system converted to geographic coordinate system (from wkid=102100 to wkid=4326)
MapPoint MapPoint = Mercator. Togeographic (G.geometry as ESRI. ArcGIS.Client.Geometry.MapPoint) as MapPoint;
Set this parameter to control where the diagram is displayed
Elementlayer.setenvelope (Infowindow, New Envelope (Mappoint.x, Mappoint.y, Mappoint.x, Mappoint.y));
ELEMENTLAYER.CHILDREN.ADD (Infowindow); Add an interface to Elementlayer
throw new System.NotImplementedException ();
}
ArcGIS API fo Silverlight Learning III (using Elementlayer to implement the mouse hover bounce custom form)