We need to determine in the code which template will be automatically applied to the related element, given the specific data type and this element.
We are not looking for a DataTemplateSelector, like the one used to indicate the user interface which template to use for this object based on user logic. Instead, we ask the user interface which template it will use for a particular data type and interface element.
In other words, we are looking for any WPF applied based on templates defined in the resource section of a window that can be overridden by the resources of a control in that window, which can be overridden by explicitly setting a DataTemplate or providing a DataTemplateSelector directly on that element.
In addition, we tried the default implementation of SelectTemplate, but this returns null, so we cannot go this route either.
The test should be to set the item without data patterns or selectors defined anywhere in the UI "How would you display this value?" and hopefully it will return a DataTemplate containing the definition for the TextBlock, with the text property set to the ToString method on this object, which is displayed by default when nothing is defined.
source share