I have a DataGrid that has AutoGenerateColumns=”True”. I’m binding that DataGrid to a collection of objects that are of an unknown datatype at design time.
The DataGrid is able to identify the data type that a particular column is bound to. It shows a textblock or a checkbox if the content is text or a bool respectively.
I want to show data in a particular way (i.e. a DataTemplate) if it’s of a specific type. Is there a way to do this?
Since you are unaware of the columns which may exist you have to revert to code behind. If you had known that you will always have 8 properties on the given object along with there types; you could move this behavior into the XAML and not have to deal with the handling of the event.
The MSDN reference sums up how to accomplish this but it boils down to handling the
AutoGeneratingColumnevent.