Gets or sets the type for which this DataTemplate is intended.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
<object> <object.DataType> <Object .../> </object.DataType> </object>
Property ValueType: System.Object
The default value is null.
This property that is very similar to the TargetType property of the Style class. When you set this property to the data type without specifying an x:Key, the DataTemplate gets applied automatically to data objects of that type. Note that when you do that the x:Key is set implicitly. Therefore, if you assign this DataTemplate an x:Key value, you are overriding the implicit x:Key and the DataTemplate would not be applied automatically.
Also note that if you are binding a ContentControl to a collection of Task objects, the ContentControl does not use the DataTemplate automatically. This is because the binding on a ContentControl needs more information to distinguish whether you want to bind to an entire collection or the individual objects. If your ContentControl is tracking the selection of an ItemsControl type, you can set the Path property of the ContentControl binding to "/" to indicate that you are interested in the current item. For an example, see How to: Bind to a Collection and Display Information Based on Selection. Otherwise, you need to specify the DataTemplate explicitly by setting the ContentTemplate property.
The property is particularly useful when you have a CompositeCollection of different types of data objects.
If this property targets an XML element that is not in the default namespace, you must precede the element name with the namespace or a namespace designator. For XML exposed through LINQ for XML, the namespace appears in braces, preceded by a brace escape sequence:
For XML exposed through XPath, the element name is preceded by a namespace designator established by an instance of XmlNamespaceMapping: