Thanks for the reply Morten,I'm sorry I'm still really green to programming and I can't figure out what to change. You can use the Map.MouseRightButtonUp event instead of the Click event.
To get the clickpoint in map coordinates where the click happened, simply do MyMap.ScreenToMap(e.GetPosition(MyMap)) in the eventhandler.
Here's my code:
private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
{
ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;
ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
{
Geometry = clickPoint,
MapExtent = Map.Extent,
Width = (int)Map.ActualWidth,
Height = (int)Map.ActualHeight,
LayerOption = LayerOption.visible
};
IdentifyTask identifyTask = new IdentifyTask("http://MapServer");
identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
identifyTask.Failed += IdentifyTask_Failed;
identifyTask.ExecuteAsync(identifyParams);
GraphicsLayer graphicsLayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
{
Geometry = clickPoint,
Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
};
graphicsLayer.Graphics.Add(graphic);
}
public void ShowFeatures(List<IdentifyResult> results)
{
_dataItems = new List<DataItem>();
if (results != null && results.Count > 0)
{
IdentifyComboBox.Items.Clear();
foreach (IdentifyResult result in results)
{
Graphic feature = result.Feature;
string title = result.Value.ToString() + " (" + result.LayerName + ")";
_dataItems.Add(new DataItem()
{
Title = title,
Data = feature.Attributes
});
IdentifyComboBox.Items.Add(title);
}
IdentifyComboBox.SelectedIndex = 0;
}
}
void cb_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int index = IdentifyComboBox.SelectedIndex;
if (index > -1)
IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data;
}
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
{
IdentifyDetailsDataGrid.ItemsSource = null;
if (args.IdentifyResults != null && args.IdentifyResults.Count > 0)
{
IdentifyResultsPanel.Visibility = Visibility.Visible;
ShowFeatures(args.IdentifyResults);
}
else
{
IdentifyComboBox.Items.Clear();
IdentifyComboBox.UpdateLayout();
IdentifyResultsPanel.Visibility = Visibility.Collapsed;
ShowIDtab.Begin();
}
}
public class DataItem
{
public string Title { get; set; }
public IDictionary<string, object> Data { get; set; }
}
void IdentifyTask_Failed(object sender, TaskFailedEventArgs e)
{
MessageBox.Show("Identify failed. Error: " + e.Error);
}
AND THEN MY XAML
<esri:Map x:Name="Map" Background="White" IsLogoVisible="False" Extent="-120.938900675217, 31.7429253923314, -114.082030001928, 38.2302170270371" Loaded="Map_Loaded" MouseClick="QueryPoint_MouseClick" >
Thanks kindly for the time.