Code snippet below:
Code:
Capture click event on the layer:
myGraphicsLayer.MouseLeftButtonUp += new GraphicsLayer.MouseButtonEventHandler(myGraphicsLayer_MouseLeftButtonUp);
void myGraphicsLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)
{
InfoWindow infowin;
GraphicsLayer gl = (GraphicsLayer)sender as GraphicsLayer;
TextBlock tb = new TextBlock();
tb.Text = "My attribute content";
tb.Margin = new Thickness(2);
tb.FontSize = 14;
//set the info window and its content to the text block (whatever control you are using)
infowin.Map = myMap;
infowin.Anchor = myMap.ScreenToMap(e.GetPosition(myMap));
infowin.Content = tb;
infowin.IsOpen = true;
infowin.Visibility = Visibility.Visible;
//add infowin to the layout
FrameworkElement parent = VisualTreeHelper.GetParent(myMap) as FrameworkElement;
((Grid)parent).Children.Add(infowin);
}
Bookmarks