3
我有三個嵌套類,Show,Season和Episode,一個節目有季節,季節有劇集。如何在代碼中綁定嵌套對象或主控細節綁定?
我想綁定兩個列表框,以便第一個列出季節,第二個列出該季節的情節。
我該怎麼做?我更喜歡在代碼,而不是XAML對此進行設置,但如果你知道如何使用XAML做到這一點,它總比沒有好..
一個simplifyed XAML:
<Window>
<Label name="Showname" />
<ListBox name="Seasons" />
<ListBox name="Episodes" />
</Window>
和一些相關代碼:
public partial class Window1 : Window
{
public Data.Show show { get; set; }
public Window1()
{
this.DataContex = show;
//Bind shows name to label
Binding bindName = new Binding("Name");
ShowName.SetBinding(Label.ContentProperty, bindName);
//Bind shows seasons to first listbox
Binding bindSeasons = new Binding("Seasons");
Seasons.SetBinding(ListBox.ItemsSourceProperty, bindSeasons);
Seasons.DisplayMemberPath = "SeasonNumber";
Seasons.IsSyncronizedWithCurrentItem = true;
//Bind current seasons episodes to second listbox
Binding bindEpisodes = new Binding("?????");
Episodes.SetBinding(ListBox.ItemsSourceProperty, bindEpisodes);
Episodes.DisplayMemberPath = "EpisodeTitle";
}
}
任何人有任何線索如何綁定第二個列表框?
人,那是快!簡單,正確。 謝謝! – Vegar 2009-02-03 21:26:38