You can create a template programatically by populating the VisualTree of the template.
[C#]
DataTemplate template = new DataTemplate();
template.VisualTree = new FrameworkElementFactory(typeof(Path));
template.VisualTree.SetBinding(Path.StrokeProperty, new Binding('Stroke'));
template.VisualTree.SetBinding(Path.StrokeThicknessProperty, new Binding('StrokeThickness'));
template.VisualTree.SetBinding(Path.FillProperty, new Binding('Interior'));
template.VisualTree.SetBinding(Path.DataProperty, new Binding('Geometry'));
Share with