问题
I want to make a binding to a specific element in the Collection. But I cannot figure out how to write the Binding. This is the code:
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-->
Try to replace those binding strings, please
Thank you
回答1:
<TextBox Text="{Binding MyCollection[0]}" />
<TextBox Text="{Binding MyCollection[1]}" />
来源:https://stackoverflow.com/questions/2854956/wpf-how-to-bind-to-a-specific-element-in-the-collection