The default DataTemplate in a wpf application displays the result of the .ToString()
method. I\'m developing an application where the default DataTemplate should di
I know of no way to do this. As per Joe's comment below, WPF specifically disallows specifying a DataTemplate
for type Object
.
Depending on your exact requirements, it may be easier to search for a DataTemplate
that matches the specific type. If you find one, use it. Otherwise, display nothing. For example:
And in your selector (pseudo-code, obviously):
var dataTemplateKey = new DataTemplateKey() { DataType = theType; };
var dataTemplate = yourControl.FindResource(dataTemplateKey);
if (dataTemplate != null)
{
return dataTemplate;
}
return NulloDataTemplate;