【发布时间】:2011-01-02 03:32:31
【问题描述】:
我有一个想要绑定到列表框的 ObservableCollection...
lbRosterList.ItemsSource = App.ViewModel.rosterItemsCollection;
但是,在那个集合中我还有另一个集合:
[DataMember]
public ObservableCollection<PersonDetail> ContactInfo
{
get
{
return _ContactInfo;
}
set
{
if (value != _ContactInfo)
{
_ContactInfo = value;
NotifyPropertyChanged("ContactInfo");
}
}
}
PersonDetail 包含 2 个属性:姓名和电子邮件
我希望列表框为 rosterItemsCollection 中的每个项目提供这些值
RosterId = 0;
RosterName = "test";
ContactInfo.name = "Art";
ContactInfo.email = "art@something.com";
RosterId = 0;
RosterName = "test"
ContactInfo.name = "bob";
ContactInfo.email = "bob@something.com";
RosterId = 1;
RosterName = "test1"
ContactInfo.name = "chris";
ContactInfo.email = "chris@something.com";
RosterId = 1;
RosterName = "test1"
ContactInfo.name = "Sam";
ContactInfo.email = "sam@something.com";
我希望列表框显示 ContactInfo 信息。
我希望这是有道理的......
我尝试过但收效甚微的 XAML:
<listbox x:Name="lbRosterList" ItemsSource="rosterItemCollection">
<textblock x:name="itemText" text="{Binding Path=name}"/>
我做错了什么?
【问题讨论】:
标签: windows-phone-7