Show、Season、Episode の 3 つの入れ子になったクラスがあり、show には季節があり、season にはエピソードがあります。
2 つのリストボックスをバインドして、最初のリストにシーズンを、2 番目にそのシーズンのエピソードをリストしたいと考えています。
これどうやってするの?私はこれを xaml ではなくコードで設定することを好みますが、xaml でそれを行う方法を知っていれば、何もないよりはましです..
単純化された 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";
}
}
2 番目のリストボックスをバインドする方法について手がかりを得た人はいますか?