【发布时间】:2010-12-12 21:13:45
【问题描述】:
给定 ThisClassShouldBeTheDataContext 类的实例作为视图的 Datacontext
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 ?????}" />
【问题讨论】:
标签: wpf xaml binding properties indexer