我使用Windows Community Toolkit在UWP中有一个数据网格,我可以毫无问题地添加字符串,当我将字符串更改为布尔值时,它将列的类型切换为选中标记列。我会使用一个类动态添加一个组合框列。我尝试将Combobox直接插入类以及可观察的集合中,但似乎没有任何作用。
我尝试将Combobox直接插入类以及可观察的集合中,但似乎没有任何作用。
public class ConditionItem : INotifyPropertyChanged
{
private string stock;
private string detail;
private string location;
private string shelflife;
private ComboBox combo;
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
public string Stock { get { return stock; } set { if (stock != value) { stock = value; OnPropertyChanged("Stock"); } } }
public string Detail { get { return detail; } set { if (detail != value) { detail = value; OnPropertyChanged("Detail"); } } }
public string Location { get { return location; } set { if (location != value) { location = value; OnPropertyChanged("Location"); } } }
public string Shelf_Life { get { return shelflife; } set { if (shelflife != value) { shelflife = value; OnPropertyChanged("Shelf_Life"); } } }
//I can't get this to display as a combobox in the Datagrid
public ComboBox Combo { get { return combo; } set { if (combo != value) { combo = value; OnPropertyChanged("Combo"); } } }
}
我希望用户能够选择一个值,然后可以从中确定一个值。