将ThisClassShouldBeTheDataContext类的一个实例作为视图的数据上下文
class ThisClassShouldBeTheDataContext
{
public Contacts Contacts {get;set;}
}
class Contacts
{
public IEnumerable<Person> Persons {get;set;}
public Person this[string Name]
{
get
{
var p = from i in Persons where i.Name = Name select i;
return p.First();
}
}
}
class Person
{
public string Name {get;set;}
public string PhoneNumber {get;set;}
}
我该如何将Contact["John"].PhoneNumber
绑定到文本框上?
<TextBox Text="{Binding ?????}" />