没有约束力的数据网格路径(WPF) [英] Not binding path in datagrid (wpf)
本文介绍了没有约束力的数据网格路径(WPF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在DataGrid列的类型为组合框,我创建列表,如果我在XAML写列出此行,位
type of column in datagrid is combobox, i create List, and list this ok, bit if i write in xaml
ItemsSource="{Binding Path=combolist}"
项目为空
我的列表
items is null my list
List<string> combolist = new List<string>();
while (reader.Read())
{
combolist.Add(reader.GetString(0));
}
为什么项目为空?
why items is null?
推荐答案
绑定只为公开属性的作用
public List<string> Combolist {get;set}
//ctor
this.Combolist = new List<string>();
while (reader.Read())
{
Combolist .Add(reader.GetString(0));
}
this.DataContext = this;
!如果您不填写构造函数列表,你应该使用的ObservableCollection名单。
!if you do not fill your list in the ctor, you should use ObservableCollection instead of list.
这篇关于没有约束力的数据网格路径(WPF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文