I have started with the identify sample code and modified it to show specific fields for a FeatureLayer. However, now I am having issues getting features, which are close to one another or on top of one another, to be returned by the identifyTask and selectable within the Grid.I believe it has something to do with the void cb_SelectionChanged
code referencing .Data instead of something else, but I am not sure.Here is a XAML snippet:<ComboBox x:Name="IdentifyComboBox" SelectionChanged="cb_SelectionChanged"
Margin="5,1,5,5" Grid.Row="0">
</ComboBox>
Here is the C# snippet: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
});
var fieldsToDisplay = new List<string>() { "OBJECTID", "Projekt", "Laufzeit", "Ansprechpa" };
var attributesToDisplay = new Dictionary<string, object>();
foreach (var item in feature.Attributes)
if(fieldsToDisplay.Contains(item.Key))
attributesToDisplay[item.Key]= item.Value;
IdentifyDetailsDataGrid.ItemsSource = attributesToDisplay;
}
IdentifyComboBox.SelectedIndex = 0;
}
}
void cb_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int index = IdentifyComboBox.SelectedIndex;
if (index > -1)
IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data;
}