How to get the default template of a control programmatically ?

Platform: WPF|Category: ControlTemplates

To get the Style for any given WPF control, get the control instance and use the ‘XAMLWriter’ class for writing the XAML related information.

[C#]

   System.Windows.Controls.TextBox t = new System.Windows.Controls.TextBox();
   StringBuilder sb = new StringBuilder();
   using (TextWriter writer = new StringWriter(sb))
   {
        System.Windows.Markup.XamlWriter.Save(t.Template, writer);
   }