void AddEventsToGraphicsLayers(Layer layer)
{
// a KmlLayer is a group layer containing other KmlLayers or the basic KML group layer, which contains
// GraphicsLayer for points, a GraphicsLayer for Polylines, a GraphicsLayer for Polygons, and an
// ElementLayer for GroundOverlays. For each of the GraphicsLayers, we will add pop-ups on tap
if (layer is GraphicsLayer)
(layer as GraphicsLayer).MouseLeftButtonUp += WebMapKML_MouseLeftButtonUp;
else if (layer is KmlLayer)
foreach (Layer childlayer in (layer as KmlLayer).ChildLayers)
AddEventsToGraphicsLayers(childlayer);
}