I have a collection consisting of two different object types, with the same base class. subclass A needs to display a button in a cell and subclass B needs to display a checkbox in a cell (the same column).
How do I accomplish this in a wpf datagrid?
The code below is purely for guidance and is not tested for compilation…
You should use DataGridTemplateColumn for this.
Specify the
DataGridTemplateColumn.CellTemplateas followsIn
SubclassToVisibilityConverter.Convert()method use the following logic…Let me know if this helps.