I am trying to add an event to my application so that when the user clicks on a graphic in a graphics layer, an InfoWindow or something similar opens. Each graphic has about 3 attributes that I want to display in the InfoWindow, one of which is a URL to an image that I would like to use as the source for an image inside of the InfoWindow. I was able to do this in Flex by putting a graphic click handler inside of a for each statement and then , but have so far been unable to translate this to Silverlight. Here is the Flex code for each statement and event handler function:
for each (myGraphicGraphical in featureSet.features)
{
var thumbURL:String = myGraphicGraphical.attributes.ThumbURL;
var fullURL:String = myGraphicGraphical.attributes.FullURL;
var imageGraphicalSym:PictureMarkerSymbol = new PictureMarkerSymbol(thumbURL,20,20,0,0,0);
myGraphicGraphical.symbol= imageGraphicalSym;
myGraphicGraphical.addEventListener(MouseEvent.CLICK,graphicClick);
graphicsGraphicalLayer.add(myGraphicGraphical);
}
private function graphicClick(event:MouseEvent):void
{
infoWindowBox.visible = true;
infoWindowBox.removeElement(infoWindowBoxImage);
label1.text = event.currentTarget.attributes.CaptureDate;
label2.text = event.currentTarget.attributes.Category;
label3.text = event.currentTarget.attributes.SourceID;
label4.text = event.currentTarget.attributes.Location;
label5.text = event.currentTarget.attributes.Purpose;
infoWindowImage = event.currentTarget.attributes.ThumbURL;
infoWindowBoxImage.source = infoWindowImage;
infoWindowBox.addElement(infoWindowBoxImage);
map.infoWindowContent = infoWindowBox;
map.infoWindow.show(map.toMapFromStage(event.stageX, event.stageY));
fullURL = event.currentTarget.attributes.FullURL;
infoWindowBoxImage.addEventListener(MouseEvent.CLICK,showFullImage);
}
I've figured out how to add a graphic click event inside of my Silverlight for each statement and event handler function, but I'm not sure how to pass something similar to "event.currentTarget" to the handler function so it knows what graphic attributes to display.