数据网格中没有绑定路径(wpf)

datagrid中的列类型是combobox,我创建了List,如果我用xaml写的话,列出这个ok,bit

ItemsSource="{Binding Path=combolist}" 

items列表为null

 List combolist = new List(); while (reader.Read()) { combolist.Add(reader.GetString(0)); } 

为什么项目为空?

组合者必须是财产。 它应该在View Model中 。 (IMO,它应该是ComboList )。

绑定只适用于公共属性

  public List Combolist {get;set} //ctor this.Combolist = new List(); while (reader.Read()) { Combolist .Add(reader.GetString(0)); } this.DataContext = this; 

!如果你没有填写ctor中的列表,你应该使用ObservableCollection而不是list。