title: DataGrid change RowDetailsTemplate dynamically
body: <p><strong>Situation:</strong></p>
  
  <p>I have a <code>DataGrid</code> where the items can belong to different categories, say <em>A</em>, <em>B</em> and <em>Custom</em>. Each Category has its own <code>RowDetails</code> template. The category of an item can be changed, and when this happens I want to change the template as well, if necessary. The ViewModel behind is the same, I just change the interface elements (for example, in template A I have a <code>TextBlock</code>, while in template B I have a <code>TextBox</code>, both with a <code>Binding</code> to the same property in the VM).</p>
  
  <p><strong>What I have done so far:</strong></p>
  
  <pre><code>&lt;DataGrid.RowDetailsTemplate&gt;
      &lt;DataTemplate&gt;
          &lt;Control x:Name="RowDetails" Focusable="False" /&gt;
              &lt;DataTemplate.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding TemplateID, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" Value="0"&gt;
                      &lt;Setter TargetName="RowDetails" Property="Template" Value="{StaticResource TemplateA}" /&gt;
              &lt;/DataTrigger&gt;
              &lt;DataTrigger Binding="{Binding TemplateID, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" Value="1"&gt;
                  &lt;Setter TargetName="RowDetails" Property="Template" Value="{StaticResource TemplateB}" /&gt;
              &lt;/DataTrigger&gt;
              &lt;DataTrigger Binding="{Binding TemplateID, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" Value="2"&gt;
                  &lt;Setter TargetName="RowDetails" Property="Template" Value="{StaticResource TemplateCustom}" /&gt;
              &lt;/DataTrigger&gt;
          &lt;/DataTemplate.Triggers&gt;
      &lt;/DataTemplate&gt;
  &lt;/DataGrid.RowDetailsTemplate&gt;
  </code></pre>
  
  <p><strong>The problem:</strong></p>
  
  <p>When I change the category of an item, I can see that the template changes, but the entire row gets the ValidationErrorTemplate (the red border, with exclamation mark). This happens even if the templates are empty! Seems to me that just changing the template makes the whole thing to explode.</p>
  
  <p>What am I doing wrong? Thanks!</p>