Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Silverlight IdentificationTask w/fieldsToDisplay不显示多个功能_C#_Silverlight_Xaml_Arcgis - Fatal编程技术网

C# Silverlight IdentificationTask w/fieldsToDisplay不显示多个功能

C# Silverlight IdentificationTask w/fieldsToDisplay不显示多个功能,c#,silverlight,xaml,arcgis,C#,Silverlight,Xaml,Arcgis,我正在尝试创建一个组合框,该组合框由IdentifyTask(该任务来自ArcGIS Silverlight API)填充。我对两件事有意见。一个创建一个列表,而另一个将该列表推出组合框。我似乎无法正确创建列表。现在,组合框仅为空 这里有一个XAML片段: <ComboBox x:Name="IdentifyComboBox" SelectionChanged="cb_SelectionChanged" Margin="5,1,5,5" Grid.

我正在尝试创建一个组合框,该组合框由IdentifyTask(该任务来自ArcGIS Silverlight API)填充。我对两件事有意见。一个创建一个列表,而另一个将该列表推出组合框。我似乎无法正确创建列表。现在,组合框仅为空

这里有一个XAML片段:

<ComboBox x:Name="IdentifyComboBox" SelectionChanged="cb_SelectionChanged"
                     Margin="5,1,5,5" Grid.Row="0">
                </ComboBox>
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;
        }

这里有一个C代码片段:

<ComboBox x:Name="IdentifyComboBox" SelectionChanged="cb_SelectionChanged"
                     Margin="5,1,5,5" Grid.Row="0">
                </ComboBox>
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;
        }
public void ShowFeatures(列出结果)
{
_dataItems=新列表();
if(results!=null&&results.Count>0)
{
var fieldsToDisplay=new List(){“OBJECTID”、“Projekt”、“Laufzeit”、“Ansprechpa”};
foreach(在结果中识别结果)
{
图形特征=结果特征;
字符串标题=result.Value.ToString()+“(“+result.LayerName+”);
var attributesToDisplay=新字典();
foreach(feature.Attributes中的变量项)
if(fieldsToDisplay.Contains(item.Key))
attributesToDisplay[item.Key]=item.Value;
_添加(新数据项()
{
头衔,
数据=属性显示
});
}
IdentifyComboBox.SelectedIndex=0;
}
}
无效cb_SelectionChanged(对象发送者,SelectionChangedEventArgs e)
{
int index=identificationComboBox.SelectedIndex;
如果(索引>-1)
IdentificationDetailsDataGrid.ItemsSource=\u dataItems[index]。数据;
}

这里遗漏了很多信息。_dataItems集合包含哪些内容。什么是“数据”ShowFeatures做了什么,下面的列表是on@ShawnKendrot谢谢你注意到这些问题。我想我已经包括了创建“数据”的事件。我现在编辑了这篇文章。希望它更能描述我遇到的问题。我猜_dataItems应该是填充ComboBox的对象,但您没有设置ComboBox的ItemsSource