title: Update DataTemplate on PropertyChanged does not work
body: <p>I have a simple object Action that has a property Code. Depending on its Code, I want to select different DataTemplates a it is also possible for the user to change the Code through a ComboBox.</p>
  
  <pre><code>public class Action : INotifyPropertyChanged
  {
      public Action()
      {
          Parameters = new List&lt;Parameter&gt;();
      }
  
      public int ActionID { get; set; }
  
      public int StepID { get; set; }
  
      public int Code { get; set; }
  
      [NotMapped]
      public List&lt;Parameter&gt; Parameters { get; set; }
  }
  </code></pre>
  
  <p>So I was looking at this answer: <a href="https://stackoverflow.com/a/18000310/2877820">https://stackoverflow.com/a/18000310/2877820</a> </p>
  
  <p>I tried the implement the solution like this:</p>
  
  <pre><code>public override DataTemplate SelectTemplate(object item, DependencyObject container)
  {
      var action = (ASI.RecipeManagement.Data.Action) item;
      if (action == null) return null;
  
      PropertyChangedEventHandler lambda = null;
      lambda = (o, args) =&gt;
      {
          if (args.PropertyName == "Code")
          {
              action.PropertyChanged -= lambda;
              var cp = (ContentPresenter)container;
              cp.ContentTemplateSelector = null;
              cp.ContentTemplateSelector = this;
          }
      };
      action.PropertyChanged += lambda;
  
      if (action.Code == 0)
          return NoParamTemplate;
  
      if (action.Code == 1)
          return OneParamTemplate;
  
      if (action.Code == 2)
      {
          if (action.Parameters[0].Type == ParameterInputTypes.List)
          {
              return ComboBoxParamTemplate;
          }
          return TwoParamTemplate;
      }
      return null;
  }
  </code></pre>
  
  <p>Sadly it does not seem to work for me. Can anybody help me out? What am I doing wrong right here?</p>