The following code snippet creates a Button control in XAML using WPF and then loads Button in a XamlReader.
Button originalButton = new Button();
originalButton.Height = 30;
originalButton.Width = 100;
originalButton.Background = Brushes.Blue;
originalButton.Content = "Click Me";
// Save the Button to a string.
string savedButton = XamlWriter.Save(originalButton);
// Load the button
StringReader stringReader = new StringReader(savedButton);
XmlReader xmlReader = XmlReader.Create(stringReader);
Button readerLoadButton = (Button)XamlReader.Load(xmlReader);