private static FrameworkElementFactory ConvertTemplateContentIntoElementFactory(WpfTemplateContent wpfTemplateContent) { var visualTree = (DependencyObject)wpfTemplateContent.Load(); var frameworkElementFactory = new FrameworkElementFactory(visualTree.GetType()); foreach (var dependencyProperty in DependencyObjectHelper.GetDependencyProperties(visualTree)) { var binding = BindingOperations.GetBinding(visualTree, dependencyProperty); var value = visualTree.GetValue(dependencyProperty); if (binding != null) { value = binding; } frameworkElementFactory.SetValue(dependencyProperty, value); } return frameworkElementFactory; }
public MyReader(WpfTemplateContent templateContent) { nodeStream = templateContent.Nodes.GetEnumerator(); CurrentIndex = 0; }