I am manually adding content presenters to the UI in my custom control and for performance reason I do not want to add them if there are no datatemples defined for the type of the content.
My use case of the data temple is that it would be defined in the resource section of some higher element in the visual tree outside of my custom control without setting the key property. I am wondering how I can check to see if a data temple for type x exist.
You can try to look it up like:
var key = new System.Windows.DataTemplateKey(typeof(x));
var r = (DataTemplate)this.FindResource(key);