Hello Tanya,You can try this
void QueryTask3_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
FeatureSet featureSet = args.FeatureSet;
if (featureSet != null && featureSet.Features.Count > 0)
{
SelectedSitesTreeView.Tag = featureSet.ObjectIdFieldName;
SelectedSitesTreeView.ItemsSource = featureSet.Features;
int count = 0;
Graphic newValue = null;
foreach (Graphic g in featureSet.Features)
{
g.Symbol = LayoutRoot.Resources["SelectMarkerSymbol"] as MarkerSymbol;
graphicsLayer.Graphics.Add(g);
newValue = g;
count = count + 1;
}
SelectedSitesTreeView.Visibility = System.Windows.Visibility.Visible;
// If there was only one graphic, change the data grid the value of this graphic/feature.
if (count == 1)
{
RoutedPropertyChangedEventArgs<object> changedGraphics = new RoutedPropertyChangedEventArgs<object>(null, newValue);
SelectedSitesTreeView_SelectedItemChanged(sender, changedGraphics);
}
}
else
{
SelectedSitesTreeView.Visibility = System.Windows.Visibility.Collapsed;
MessageBox.Show("No samples found here, please try another location.");
}
}