title: ItemTemplateSelector not working for ListView without Binding
body: <p>I have a ListView whose ItemsSource I set programmatically in the code behind. I used to only have one Template but now I want to use multiple templates and select the template according to the item I add to the ListView.</p>
  
  <p>This is the XAML Code I have:</p>
  
  <pre><code>&lt;Page.Resources&gt;
  &lt;local:TemplateSelector x:Key="myTemplateSelector" TemplateA="{StaticResource TemplateA}" TemplateB="{StaticResource TemplateB}" /&gt;
  
  &lt;!-- TemplateA and TemplateB --&gt;
  &lt;/Page.Resources&gt;
  
   &lt;ListView
          x:Name="MasterListView"
          Grid.Row="1"
          ItemContainerTransitions="{x:Null}" 
          ItemTemplateSelector="{StaticResource myTemplateSelector}"
          IsItemClickEnabled="True"
          ItemClick="MasterListView_ItemClick"/&gt;
  </code></pre>
  
  <p>I then set the ItemSource of the ListView and this is my TemplateSelector:</p>
  
  <pre><code>  public class TemplateSelector : DataTemplateSelector
  {
      public DataTemplate TemplateA { get; set; }
      public DataTemplate TemplateB { get; set; }
  
      public new DataTemplate SelectTemplate(object item, DependencyObject container)
      {
  
          return TemplateA;
      }
  }
  </code></pre>
  
  <p>However, this does not work. Instead of my desired template I always get the same text for every item: AppName.ViewModels.ViewModel1 (the type of the data I want to show).</p>
  
  <p>In the past when I only had one itemtemplate I used this in the xaml and it worked:</p>
  
  <pre><code>        &lt;ListView
          x:Name="MasterListView"
          Grid.Row="1"
          ItemContainerTransitions="{x:Null}" 
          ItemTemplate="{StaticResource TemplateA}"
          IsItemClickEnabled="True"
          ItemClick="MasterListView_ItemClick"/&gt;
  </code></pre>
  
  <p>How can I get the ItemTemplateSelector to work? I placed breakpoints there but it does not even get called.</p>