title: WPF Combo Box not displaying dynamically changed selected item
body: <p>I am trying to change the selected item of a combo box based on a change in another combo box. The situation is complicated by the fact that both combo boxes appear in a list of item templates.</p>
  
  <p>The XAML is as follows:</p>
  
  <pre><code>&lt;ListBox ItemsSource="{Binding AncillaryExtendedPropertyViewModels}" ItemTemplateSelector="{StaticResource templateSelector}"/&gt;
  
  &lt;DataTemplate x:Key="EnumDataTemplate"&gt; &lt;Grid Margin="4"
  MinHeight="25"&gt; &lt;ComboBox SelectedItem="{Binding ExtendedPropertyEnum,
  UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
  ItemsSource="{Binding ExtendedPropertyEnumList}"
  DisplayMemberPath="Value"/&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>The data context of the view containing the XAML is set to AncillaryBaseViewModel. The following is a cut down version of AncillaryBaseViewModel.</p>
  
  <pre><code>public class AncillaryBaseViewModel : ComplexOrderItemViewModel, IDataErrorInfo
      {
          private ObservableCollection&lt;ExtendedPropertyViewModel&gt; _ancillaryExtendedPropertyViewModels;
  
  public ObservableCollection&lt;ExtendedPropertyViewModel&gt; AncillaryExtendedPropertyViewModels
          {
              get { return _ancillaryExtendedPropertyViewModels; }
              set
              {
                  _ancillaryExtendedPropertyViewModels = value;
                  OnPropertyChanged("AncillaryExtendedPropertyViewModels");
              }
          }
  </code></pre>
  
  <p>and the ExtendedPropertyViewModel class....</p>
  
  <pre><code>    public class ExtendedPropertyViewModel : DataTemplateSelector
      {
          private ExtendedProperty _extendedProperty;
          public DataTemplate DefaultnDataTemplate { get; set; }
          public DataTemplate BooleanDataTemplate { get; set; }
          public DataTemplate EnumDataTemplate { get; set; }
  
          public ExtendedPropertyEnum ExtendedPropertyEnum
          {
          get
          { return ExtendedProperty.ExtendedPropertyEnum; }
          set
          {
              if (ExtendedProperty.ExtendedPropertyEnum != value)
              {
                  _extendedProperty.ExtendedPropertyEnum = value;
                  AncillaryBaseViewModel parent = RequestParent();
                  if (parent != null)
                  { 
  parent.AncillaryExtendedPropertyViewModels[7].ExtendedPropertyEnum = 
  ExtendedProperty.ExtendedPropertyEnum.DependentExtendedPropertyEnums[0];
                  }
                  parent.OrderItem.SetStockCode();
                  PropertyChanged += parent.OnExtendedPropertyChanged;
                  OnPropertyChanged();
              }
          }
      }
  </code></pre>
  
  <p>and the ExtendedProperty class....</p>
  
  <pre><code>public class ExtendedProperty : ViewModelBase
  {
      private ExtendedPropertyEnum _extendedPropertyEnum;
      public int ExtendedPropertyID { get; set; }
      public int OrderItemTypeID { get; set; }
      public string DisplayName {get; set;}
      public ObservableCollection&lt;ExtendedPropertyEnum&gt; ExtendedPropertyEnumList { get; set; }
      public string Value { get; set; }
  
      public ExtendedPropertyEnum ExtendedPropertyEnum
      {
          get
          {
              return _extendedPropertyEnum;
          }
          set
          {
              _extendedPropertyEnum = value;
              OnPropertyChanged("ExtendedPropertyEnum");
          }
      }
  }
  </code></pre>
  
  <p>To summarise, when I change the value of combo box A through the UI, this calls the ExtendedPropertyEnum setter within ExtendedPropertyViewModel, which changes the ExtendedPropertyEnum bound to another combo box B, which is in the same list. I would expect this to update the value displayed in combo box B accordingly, which it does not.
  As an aside, changing the value of combo box A does update a label that is not within a data template. The XAML for this label is....</p>
  
  <pre><code>&lt;Label Content="{Binding StockCode}" MinWidth="100"/&gt;
  </code></pre>
  
  <p>This is updated by the following code within AncillaryBaseViewModel....</p>
  
  <pre><code>public void OnExtendedPropertyChanged(object sender, EventArgs args)
  {
      OnPropertyChanged("StockCode");
  }
  </code></pre>
  
  <p>I thought I could change this to the following to force the combo boxes in the list to update.</p>
  
  <pre><code>public void OnExtendedPropertyChanged(object sender, EventArgs args)
  {
      OnPropertyChanged("StockCode");
      OnPropertyChanged("AncillaryExtendedPropertyViewModels");
  }
  </code></pre>
  
  <p>However, this did not work either.</p>
  
  <p>Any help greatly appreciated.
  Roger.</p>