I have a three nested classes, Show, Season and Episode, where a show has seasons, and seasons has episodes.
I want to bind two listboxes so that the first lists seasons, and the second lists episodes in that season.
How can I do this? I prefer to set this up in code, not xaml, but if you know how to do it with xaml, it's better than nothing..
A simplifyed xaml:
<Window>
<Label name="Showname" />
<ListBox name="Seasons" />
<ListBox name="Episodes" />
</Window>
and some relevant code:
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";
}
}
Anyone got any clues how to bind up the second listbox?