Example #1
0
        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;
        }
Example #2
0
 public MyReader(WpfTemplateContent templateContent)
 {
     nodeStream = templateContent.Nodes.GetEnumerator();
     CurrentIndex = 0;
 }