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