We need to determine, in code, what template would automatically be applied to a bound element, given a specific data type and that element.
We are not looking for a DataTemplateSelector as that's used to tell the UI which template to use for a given object based on custom logic. We're instead asking the UI which template will it use for a given data type and UI element.
In other words, we're looking for whatever WPF would apply based on the templates defined in the resources section of a window, which can be overridden by the resources of a control on that window, which can be overridden by explicitly setting the DataTemplate or providing a DataTemplateSelector directly on that element.
Also, we tried the default implementation of SelectTemplate but that returns null, so we can't go that route either.
A test would be to ask an element with no data templates or selectors defined anywhere in the UI 'How would you display this value?' and hopefully it will return a DataTemplate containing the definition for a TextBlock with the text property set to the ToString method on that object, which is what's displayed by default when nothing else is defined.