Reid had already considered the Build Your Own XAML approach, but just to give an illustration of the FrameworkElementFactory approach, it would look something like this.
First create an FEF:
var fef = new FrameworkElementFactory(typeof(TextBlock)); fef.SetBinding(TextBlock.TextProperty, new Binding("Name"));
Then create a DataTemplate with its VisualTree set to factory:
DataTemplate dt = new DataTemplate { VisualTree = fef };
Although, as Reid notes, the FrameworkElementFactory approach is officially deprecated, it is still widely used, I think because the structure of the XAML lines seems so ragged. (Although the FEF approach quickly becomes insanely complex if you have a non-trivial template ...!)
source share