【发布时间】:2020-10-06 03:39:46
【问题描述】:
我的对象如下所示:
public class Macro : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propName));
}
private string name = "";
public string Name
{
get { return this.name; }
set
{
this.name = value;
this.NotifyPropertyChanged("Name");
}
}
private ObservableCollection<int> listParams = new ObservableCollection<int>();
public ObservableCollection<int> ListParams
{
get { return this.listParams; }
set
{
this.listParams = value;
this.NotifyPropertyChanged("ListParams");
}
}
public Macro()
{
}
public Macro(string nom)
{
this.Name = nom;
}
}
在我的 XAML 中,我想创建一个 TextBoxes 绑定到 ListParams[0],ListParams[1]... ListParams[20] 的列表。这有可能进行这样的绑定吗?到目前为止,我只创建了 20 个“参数”(int p0, int p1, int p2...),但我正在考虑一种让我的对象更容易的方法。
【问题讨论】:
-
使用绑定到
ListParams的ItemsControl?