title: ContentControl.ContentTemplateSelector dynamically select template
body: <p>I set a ContentControl in the right of Window, and set Content binding Items (it's type is ObservableCollection). Now I want to achieve it: if there are no item, ContentControl select first DataTemplate,  and add a item into items, ContentControl will select second DataTemplate to display some info. </p>
  
  <p>Like this:</p>
  
  <p><img src="https://i.stack.imgur.com/W5BTz.png" alt="enter image description here"></p>
  
  <p>The problem is when I add one item into items, ContentControl didnot update and change DataTemplate, I have a try to set mode, UpdateSourceTrigger, etc., but failed. In ViewModel, after delete a item, I use this statements, it will work well <strong>&lt;1></strong>:</p>
  
  <pre><code>private void ExecuteDeleteClientCommand()
  {
      ...
      if (DeleteClient(item))
      {
          ObservableCollection&lt;MyViewModel&gt; tmp = TabItems;
          TabItems = null;
          TabItems = tmp;
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>&lt;ContentControl 
      ContentTemplateSelector="{StaticResource MyDataTemplateSelector}" 
      Content="{Binding Items}"/&gt;
  </code></pre>
  
  <p>.</p>
  
  <pre><code>public class SingleClientDataTemplateSelector : DataTemplateSelector
  {
      public override DataTemplate SelectTemplate(object item, 
          DependencyObject container)
      {
          ObservableCollection&lt;MyViewModel&gt; obj = 
              item as ObservableCollection&lt;MyViewModel&gt;;
          if (null == obj || 0 == obj.Count)
          {
              return App.Current.FindResource("NullItemDataTemplate") as DataTemplate;
          }
          return App.Current.FindResource("DefaultDataTemplate") as DataTemplate;
      }
  }
  </code></pre>
  
  <p><strong>Edited:</strong>
  use this way is also failed after delete one item:</p>
  
  <pre><code>RaisePropertyChanging(ItemsPropertyName);
  RaisePropertyChanged(ItemsPropertyName);
  </code></pre>
  
  <p>but I wonder why it work well with <strong>&lt;1></strong>.</p>
  
  <p><strong>Edited2</strong>
  It's the delcaration:</p>
  
  <pre><code>public const string ItemsPropertyName = "Items";
  private ObservableCollection&lt;MyViewModel&gt; items = new ObservableCollection&lt;MyViewModel&gt;();
  public ObservableCollection&lt;SingleClientDetailViewModel&gt; TabItems
  {
      get { return items; }
      set 
      { 
          if (items == value) { return;}
          RaisePropertyChanging(ItemsPropertyName);
      items = value;
      RaisePropertyChanged(ItemsPropertyName);
      }
  }
  </code></pre>