我正在动态填充listView,结果我将每个文本框绑定到属性。我有类似:以编程方式将TextBlock绑定到数组索引
System.Windows.FrameworkElementFactory f = new System.Windows.FrameworkElementFactory(typeof(System.Windows.Controls.TextBlock));
f.SetValue(System.Windows.Controls.TextBox.FontWeightProperty, System.Windows.FontWeights.Normal);
Binding myBinding = new Binding("SomeProperty");
f.SetBinding(System.Windows.Controls.TextBlock.TextProperty, myBinding);
如果列表视图充满例如对象动物和动物类有一个名为SomeProperty里面的属性然后在列表视图的列将包含SomeProperty的价值。我想要做的是绑定到一个字符串数组例如。假设我有同样的动物类,并且当我做一些像它不绑定的新Binding(“array [1]”)时,动物就有一个字符串数组。只有当我对某个属性进行操作时它才具有约束力。或者也许有一种制作属性数组的方法。这将是很好,如果我可以将数据绑定到数组索引
据我所知,你不能那样做,你必须在绑定中选择属性名称 – Homam 2011-05-10 05:39:10