---
title: "XAML - Use different template based on class"  
description: "XAML - Use different template based on class"  
author: "Anonymous User"  
published: 2013-09-25  
updated: 2013-09-25  
canonical: https://www.mindstick.com/forum/1527/xaml-use-different-template-based-on-class  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# XAML - Use different template based on class

I have a [nested](https://www.mindstick.com/forum/45/itemcommand-event-in-nested-repeater-and-listview) datagrid. The grid is bound to a EquipmentListViewModel, which then contains a list of EquipmentViewModels. Each row can be dropped down by clicking a "+" [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) which will display a list of Frequencies for that [equipment](https://www.mindstick.com/blog/301024/best-home-gym-equipment-for-2022). I want to be able to display different RowDetailsTemplates depending on the CLASS of the row. The following is an example of what I want to do:

-BaseClass(Hit + button to [dropdown](https://www.mindstick.com/articles/263/ajax-toolkit-dropdownextender-in-asp-dot-net) equipment list below)

-EquipmentTypeA(Should have a + button to [drop down](https://www.mindstick.com/forum/263/drop-down-list-problem), is of class "TypeA")

-Frequencies

-EquipmentTypeB(Doesnt contain a + buton, so it is different than EquipmentTypeA, of class "TypeB")

How can I have BaseClass contain a list of EquipmentTypes, where each row implements a [derived class](https://answers.mindstick.com/qa/30686/what-is-a-base-class-and-derived-class) from the EquipmentTypes [base](https://www.mindstick.com/articles/12627/how-can-predictive-analytics-enhance-customer-base-and-experience) class(TypeA,TypeB,etc). This way I can have each row have [custom](https://www.mindstick.com/blog/12298/use-custom-writing-services-to-get-through-the-finals) code depending on its class type(if it should contain a button, etc).

## Replies

### Reply by Anonymous User

Hi Ashish,

Instead of specifying RowDetailsTemplates explicitly, just make sure that the visual tree contains a DataTemplate for each [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) (EquipmentTypeA and EquipmentTypeB) you wish to display. These will get used by default if the template is not specified.


---

Original Source: https://www.mindstick.com/forum/1527/xaml-use-different-template-based-on-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
