title: ListBox selectedItem get working but set not working in MVVM
body: <p>I am working on a WPF application and following MVVM. In my view there is a grid view which contains different columns. One of these column is a ListBox. Now problem is that for the ListBox column, SelectedItem get works fine but set doesn't.</p>
  
  <p>Here is my View code</p>
  
  <pre><code>&lt;DataGrid ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" SelectionMode="Single"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn Binding="{Binding Name}" Header="Name" /&gt;
          &lt;DataGridTemplateColumn Header="Actions"&gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;ListBox DisplayMemberPath="Name" ItemsSource="{Binding Actions}" SelectedItem="{Binding SelectedAction}" /&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
          &lt;/DataGridTemplateColumn&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>In my ViewModel, I have Main ViewModel class, which contains a list of Items. Item class contains name, a list of actions and selected action.</p>
  
  <pre><code>public class MyViewModel : INotifyOfPropertyChanged
  {
      private ObservableCollection&lt;Item&gt; _items;
      public ObservableCollection&lt;Item&gt; Items
      {
          get { return _items?? (_items= new ObservableCollection&lt;Item&gt;); }
      }
  
      private Item _selectedItem;
      public Item SelectedItem
      {
          get { return _selectedItem; }
          set { _selectedItem= value; }
      }
  }
  
  public class Item : INotifyOfPropertyChanged
  {
      public string Name;
  
      private ObservableCollection&lt;string&gt; _actions;
      public ObservableCollection&lt;string&gt; Actions
      {
          get { return _actions?? (_actions= new ObservableCollection&lt;string&gt;); }
      }
  
      private string _selectedAction;
      public string SelectedAction
      {
          get { return _selectedAction; }
          set { _selectedAction = value; }
      }
  }
  </code></pre>
  
  <p>Now SelectedItem for Items list works fine. But SelectedItem insde Item class for Actions doesn't work completely. I inserted breakpoints on getter and setter of SelectedAction. get breakpoint hits. But if I select an action from the UI then set breakpoint for SelectedAction doesn't get hit. </p>
  
  <p>What's the problem.</p>
  
  <p><img src="https://i.stack.imgur.com/B9dRT.png" alt="View"></p>
  
  <p>When I select Archive Project or Restore Project, setter of SelectedAction doesn't get called.</p>
  
  <p><strong>NOTE:</strong> I have removed unnecessary information like loading data in lists, implementation of INotifyOfPropertyChanged etc.</p>