I have a FrameworkElement, such as StackPanel with children, I need to create a DataTempltate whose VisualTree property is my FrameworkElement. To do this work I need to convert my FrameworkElement in the equivalent FrameworkElementFactory.
How can I do?
You can probably use the XamlWriter and XamlReader classes to get a copy of the XAML used in your control, and use it to build another control
I think this will only copy the
StackPanel, so you'll probably have to copy it's children the same way too.Also per the Remarks section on MSDN for the FrameworkElementFactory