0
我想将绑定到集合中的特定元素。 但我不知道如何编写绑定。 这是代码:WPF如何绑定到集合中的特定元素
public class MySource
{
..
public string SomeProp;
public ICollection<T> MyCollection;
..
}
this.DataContext = new MySource();
<TextBox Text={Binding SomeProp} />
<TextBox Text={Binding FIRST_ELEMENT_OF_THE_MyCollection} />
<TextBox Text={Binding SECOND_ELEMENT_OF_THE_MyCollection} />
<!--Ignore other elements-->
试图取代那些绑定字符串,请
谢谢
如果你从里面的元素需要一个属性,你可以这样写:{绑定MyCollection [0] .Property}? – 2010-05-18 06:43:18
是的。它应该在WPF中工作。如果不是,您可以在ViewModel中使用两个属性。 – Amsakanna 2010-05-18 06:58:26