Date: 17.01.2017 3:55:44
используя класс XamlReader:
using System;
using System.Windows;
using System.Windows.Controls;
using System.IO;
using System.Xml;
using System.Windows.Markup;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
StreamReader rdr = new StreamReader("myControl.xaml");
XmlReader xmlReader = XmlReader.Create(rdr);
object obj=XamlReader.Load(xmlReader);
this.Content = (FrameworkElement)obj;
}
}
}
затем скармливаете ему что-то такое:
<Grid xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> <Button Content='Hello, World' HorizontalAlignment='Left' Margin='77,62,0,0' VerticalAlignment='Top' Width='75'/> </Grid>
Автор: VadimTagil