foreach (Graphic graphic in args.FeatureSet.Features)
{
QueryComboBox.Items.Add(graphic.Attributes["STATE_NAME"].ToString());
}
foreach (Graphic graphic in args.FeatureSet.Features)
{
//Set Distinct
QueryComboBox.Items.Add = (from g in args.FeatureSet.Features
orderby g.Attributes["STATE_NAME"].ToString()
select g.Attributes["STATE_NAME"]).Distinct();
}
QueryComboBox.SelectedIndex = 0;
return;
esrijay is right. you will need to use a linq query to filter out your redundant states and populate your combobox with unique entries.
.
You might also have to add the ref to your app.
Right click Reference folder
Click add reference
Click the .Net Tab
Find System.Xml.Linq
Add.
Hope that works.
var states = (from g in args.FeatureSet.Features select g.Attributes["STATE_NAME"]).Distinct().OrderBy(s => s); QueryComboBox.ItemsSource = states;
string[] states = args.FeatureSet.Features.Select(s => s.Attributes["STATE_NAME"].ToString()).Distinct().OrderBy(t => t).ToArray(); QueryComboBox.ItemsSource = states;