Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.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# 绑定列表<;KeyValuePair<;字符串,列表<;数据表>&燃气轮机&燃气轮机;项目控制wpf_C#_Wpf_Binding_Itemscontrol - Fatal编程技术网

C# 绑定列表<;KeyValuePair<;字符串,列表<;数据表>&燃气轮机&燃气轮机;项目控制wpf

C# 绑定列表<;KeyValuePair<;字符串,列表<;数据表>&燃气轮机&燃气轮机;项目控制wpf,c#,wpf,binding,itemscontrol,C#,Wpf,Binding,Itemscontrol,当列表中的键值对项展开时,我需要显示2个数据表。键值对项的键应该是扩展器头。 第一个表应该绑定到第一个数据网格,第二个表绑定到第二个网格。 问题是ItemsControl上的第二个“item”显示的值与第一个相同。 (我的猜测是datagrid的ItemsSource绑定不正确,因为VM正确地生成了ListOfKeyValuePairs的数据。) 您的代码工作正常。但是您在值模板中使用的是网格。两项 <DataGrid ItemsSource="{Binding [0]}" />

当列表中的键值对项展开时,我需要显示2个数据表。键值对项的键应该是扩展器头。 第一个表应该绑定到第一个数据网格,第二个表绑定到第二个网格。 问题是ItemsControl上的第二个“item”显示的值与第一个相同。 (我的猜测是datagrid的ItemsSource绑定不正确,因为VM正确地生成了ListOfKeyValuePairs的数据。)



您的代码工作正常。但是您在
值模板中使用的是
网格
。两项

<DataGrid ItemsSource="{Binding [0]}" />
<DataGrid ItemsSource="{Binding [1]}" />

或者使用一个简单的
StackPanel

presentationContraceSources.TraceLevel=High
放入您怀疑的任何绑定中。像这样:
{Binding Foo,PresentationTraceSources.TraceLevel=High}
。在调试器中运行程序,并查看在VS中的输出窗格中看到的输出。它将告诉您如何找到绑定的目标——如果失败,它将告诉您找到了什么(如果有)。
<DataGrid ItemsSource="{Binding [0]}" />
<DataGrid ItemsSource="{Binding [1]}" />
<DataGrid Grid.Row="0" ItemsSource="{Binding [0]}" />
<DataGrid Grid.Row="1" ItemsSource="{Binding [1]}" />