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);
}
Share with