Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 121917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:02:47+00:00 2026-05-11T04:02:47+00:00

I have a three nested classes, Show, Season and Episode, where a show has

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T04:02:47+00:00Added an answer on May 11, 2026 at 4:02 am

    Edit: adding a bit more details.

    Ok, so let’s say you have a Show object. This has a collection of Seasons. Each Season has a collection of Episodes. You can then have the DataContext for the entire control be the Show object.

    • Bind your TextBlock to the show’s Name. Text='{Binding Name’}
    • Bind the ItemsSource of the seasons list box to the Seasons collection. ItemsSource='{Binding Seasons}’ IsSynchronizedWithCurrentItem=’True’
    • Bind the ItemsSource of the episodes list box to the current Season’s Episodes collection. ItemsSource='{Binding Seasons/Episodes}’.

    Assuming your Window’s DataContext is the Show object, the XAML would be:

    <Window>    <TextBlock Text='{Binding Name}' />    <ListBox ItemsSource='{Binding Seasons}' IsSynchronizedWithCurrentItem='True' />    <ListBox ItemsSource='{Binding Seasons/Episodes}' />    </Window> 

    So your UI elements don’t really need names. Also, to translate this into code is pretty easy and you were on the right path. The main issue with your code was that you were naming the list boxes, when they don’t really need it.

    Assuming the Season object has a property called Episodes, which is a collection of Episode objects, I think it is:

     Binding bindEpisodes = new Binding('Seasons/Episodes'); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I'm talking about here are nested classes. Essentially, I have two classes that
Have three divs in a container that I want to float over a large
I have three files: one called sql.php witch has a class db that I
I have been writing several class templates that contain nested iterator classes, for which
I have an object with nested parts persisted over three tables. The classes are
how to implement inner outer classes in c# i have two nested classes like
I have a structure that can be very easily represented using a three-deep nested
I have two closely related classes which I'll call Widget and Sprocket. Sprocket has
I have several models that includes nested classes and lists. Many of the class
I've got question about nested inheritance in C++. I have three classes: Base ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.