views:

39

answers:

1

Hi,

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

A: 
<TextBox Text="{Binding MyCollection[0]}" /> 
<TextBox Text="{Binding MyCollection[1]}" />
Veer
And if you Need a property from inside the element, can you write this: {Binding MyCollection[0].Property} ?
PaN1C_Showt1Me
Yes. It should work in WPF. If not you can use two properties in ViewModel.
Veer