title: MVVM: Populate a view (with listbox) when an item from another view (with listbox) is selected
body: <p>I have a list of Topics, and for each topic there are some Examples. What I want to be able to do is that when a topic is selected then I will populate another view with all Examples for that selected topic. I'm still learning MVVM so not sure how to implement such.</p>
  
  <p>EDIT:
  What I am attempting to do is to have two separate views (1 for the topics and 1 for the examples), and when an a topic is selected then I will 'dynamically' populate the collection of the examples and show them in the listbox of the examples' view.</p>
  
  <p>This is what I have so far, my idea is to pass the ViewModel of example to the TopicViewModel, but I am unsure how to do it if both views are set in the XAML of the main window:</p>
  
  <pre><code>public TopicViewModel SelectedTopic
  {
      get { return _selectedTopic; }
      set
      {
          _selectedTopic = value;
          OnPropertyChanged("SelectedTopic");
  
          //refresh list of exercises
          if (_exampleViewModel != null)
          {
              _exampleViewModel.RefreshExercises(_selectedTopic.ID);
          }
      }
  }
  </code></pre>