0
所以我有以下型號:WPF組合框綁定
public class Person
{
public String FirstName { get; set; }
public String LastName { get; set; }
public String Address { get; set; }
public String EMail { get; set; }
public String Phone { get; set; }
}
public class Order
{
public Person Pers { get; set;}
public Product Prod { get; set; }
public List<Person> AllPersons { get; set; }
public Order(Person person, Product prod)
{
this.Pers = person;
this.Prod = prod;
AllPersons = database.Persons.GetAll();
}
}
而且我用修改訂單WPF窗口。 我將DataContext設置爲Order。
public SetDisplay(Order ord)
{
DataContext = ord;
}
我有以下XAML:
<ComboBox Name="myComboBox"
SelectedItem = "{Binding Path=Pers, Mode=TwoWay}"
ItemsSource = "{Binding Path=AllPersons, Mode=OneWay}"
DisplayMemberPath = "FirstName"
IsEditable="False" />
<Label Name="lblPersonName" Content = "{Binding Path=Pers.FirstName}" />
<Label Name="lblPersonLastName" Content = "{Binding Path=Pers.LastName}" />
<Label Name="lblPersonEMail" Content = "{Binding Path=Pers.EMail}" />
<Label Name="lblPersonAddress" Content = "{Binding Path=Pers.Address}" />
然而,結合似乎不工作.......當我改變所選擇的項目,標籤不更新.. ..
Regards !!
任何回覆讚賞!
你肯定那人卻在AllPersons收藏? AllPersons.Contains(person)在構造函數中返回true嗎?我覺得不是!不要忘記標記有用的帖子作爲答案,否則沒有人會在未來幫助你 – 2010-03-19 14:00:19
是的 - 人是100%肯定會在AllPersons colleciton – MadSeb 2010-03-19 15:29:42