Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are the default WPF Control Templates? [duplicate]

The default Control Templates exist, obviously, in binary form in the different DLLs that we add as "References" to each of our projects.

Do they exist in ASCII/source form somewhere? Are they available?

TIA


1 Answers

There are free tools available to explore the templates of the default wpf controls, e.g. Show Me The Template! (there are also tools for control styles, see StyleSnooper).

Alternatively you can explore templates with the following:

private string getTemplate(Control control)
{
    StringBuilder stringBuilder = new StringBuilder();

    XmlWriterSettings xmlSettings = new XmlWriterSettings();
    xmlSettings.Indent = true;

    using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, xmlSettings))
    {
        XamlWriter.Save(control.Template, xmlWriter);
    }
    return stringBuilder.ToString();
}
like image 90
EKrueger Avatar answered Oct 26 '25 15:10

EKrueger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!