Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.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
WPF组合框绑定到DataTable无效_Wpf_Data Binding_Combobox - Fatal编程技术网

WPF组合框绑定到DataTable无效

WPF组合框绑定到DataTable无效,wpf,data-binding,combobox,Wpf,Data Binding,Combobox,组合框定义为 <ComboBox Name="cmbCallSource" /> 我尝试了两种方法(第二种被注释掉)。无论哪种方式,组合框最终都是空的。这里缺少什么?设置Itemsource属性,而不是DataContext cmbCallSource.ItemsSource = dtSources.DefaultView; cmbCallSource.ItemsSource = dtSources.DefaultView;

组合框定义为

<ComboBox Name="cmbCallSource" />

我尝试了两种方法(第二种被注释掉)。无论哪种方式,组合框最终都是空的。这里缺少什么?

设置Itemsource属性,而不是DataContext

cmbCallSource.ItemsSource = dtSources.DefaultView;
cmbCallSource.ItemsSource = dtSources.DefaultView;