IdentifyTask から入力された ComboBox を作成しようとしています (タスクは ArcGIS Silverlight API から取得されます)。2 つのイベントで問題が発生しています。1 つはリストを作成し、もう 1 つはそのリストを ComboBox にプッシュします。リストを正しく作成できないようです。現在、ComboBox は空白のみです。
XAML スニペットを次に示します。
<ComboBox x:Name="IdentifyComboBox" SelectionChanged="cb_SelectionChanged"
Margin="5,1,5,5" Grid.Row="0">
</ComboBox>
C# のスニペットを次に示します。
public void ShowFeatures(List<IdentifyResult> results)
{
_dataItems = new List<DataItem>();
if (results != null && results.Count > 0)
{
var fieldsToDisplay = new List<string>() { "OBJECTID", "Projekt", "Laufzeit", "Ansprechpa" };
foreach (IdentifyResult result in results)
{
Graphic feature = result.Feature;
string title = result.Value.ToString() + " (" + result.LayerName + ")";
var attributesToDisplay = new Dictionary<string, object>();
foreach (var item in feature.Attributes)
if (fieldsToDisplay.Contains(item.Key))
attributesToDisplay[item.Key] = item.Value;
_dataItems.Add(new DataItem()
{
Title = title,
Data = attributesToDisplay
});
}
IdentifyComboBox.SelectedIndex = 0;
}
}
void cb_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int index = IdentifyComboBox.SelectedIndex;
if (index > -1)
IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data;
}