//File:Window.xaml.cs using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Markup; using System.Xml; using System.IO; namespace WpfApplication1 { public partial class Window1 : System.Windows.Window { public Window1() { InitializeComponent(); StringReader sr = new StringReader(@" Foreground='BurlyWood' FontSize='20pt'>Click Me!"); XmlReader reader = XmlReader.Create(sr); Button dynamicButton = (Button)XamlReader.Load(reader); this.grid1.Children.Add(dynamicButton); dynamicButton.Click += button1_Click;