Home > DeveloperSection > Forums > XAML - Use different template based on class
Ashish Pandey

Total Post:128

Posted on    September-25-2013 3:07 AM


 1 Reply(s)
 797  View(s)
Rate this:

I have a nested 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 which will display a list of Frequencies for that equipment. 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 equipment list below)

   -EquipmentTypeA(Should have a + button to drop down, is of class "TypeA")


   -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 from the EquipmentTypes base class(TypeA,TypeB,etc). This way I can have each row have custom code depending on its class type(if it should contain a button, etc).

ezra heywood
ezra heywood

Total Post:145

Posted on    September-25-2013 4:29 AM

Hi Ashish,

Instead of specifying RowDetailsTemplates explicitly, just make sure that the visual tree contains a DataTemplate for each class (EquipmentTypeA and EquipmentTypeB) you wish to display. These will get used by default if the template is not specified.

Don't want to miss updates? Please click the below button!

Follow MindStick