title: WPF DataGrid: Selecting CellTemplate by DataType of ItemsSoure
body: <p>I am Building a DataGrid where i want to switch the images inside a cell based on the underlying datatype of the current item.</p>
  
  <p>Question: 
  Is it possible to apply this type of template switching?
  Preferably in xaml-only?</p>
  
  <p>ItemsSource is</p>
  
  <pre><code>ObservableCollection&lt;BaseModel&gt;
  </code></pre>
  
  <p>which contains Items of type</p>
  
  <pre><code>IncidentModel : BaseModel
  ServiceModel : BaseModel
  </code></pre>
  
  <p>This is where i currently am:</p>
  
  <pre><code>&lt;DataGrid 
      ItemsSource="{Binding TicketCollection,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}"
      IsReadOnly="True"
      AutoGenerateColumns="False"
      DockPanel.Dock="Top"&gt;
  
      &lt;DataGrid.Resources&gt;
          &lt;DataTemplate DataType="{x:Type models:IncidentModel}"&gt;
              &lt;Image Source="pack://application:,,,/SMLib;component/Files/Images/16x16/Active_16.png" /&gt;
  
          &lt;/DataTemplate&gt;
          &lt;DataTemplate DataType="{x:Type models:ServiceModel}"&gt;
              &lt;Image Source="pack://application:,,,/SMLib;component/Files/Images/16x16/IncidentMgmt_AllIncidents_16.png" /&gt;
  
          &lt;/DataTemplate&gt;
      &lt;/DataGrid.Resources&gt;
  
      &lt;DataGrid.Columns&gt;
  
          &lt;DataGridTemplateColumn Header="Typ"&gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
  
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
          &lt;/DataGridTemplateColumn&gt;
  
          &lt;DataGridTextColumn Header="Id" Binding="{Binding Id,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" /&gt;
          &lt;DataGridTextColumn Header="Titel" Binding="{Binding Title,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" /&gt;
          &lt;DataGridTextColumn Header="Status" Binding="{Binding Status,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" /&gt;
          &lt;DataGridTextColumn Header="Erstellung" Binding="{Binding CreatedDate,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" /&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Thanks for every possible help!</p>