3

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

  • You will probably need a source license from Microsoft. – Travis Banger Jun 18 '14 at 00:29
  • @TravisBanger I don't need one to see the ones on MSDN... – BradleyDotNET Jun 18 '14 at 00:30
  • Can you provide a better link? The ones you provided are not even clickable. I found the word "Classic.xaml", looked for it in my hard disk, found it in the Windows SDK. It was inside a compressed file. It was useless. –  Jun 18 '14 at 00:35
  • "I don't need one to see the ones on MSDN" Care to share one with the readers? They are XAML files, correct? Care to name the title, or number of lines of ONE? –  Jun 18 '14 at 00:40
  • @swiss_programmer, I clicked on the "ListView" one, and it was 341 lines long. Its not in a file (its formatted text on the screen) but its pretty easy to copy paste... By the way, I didn't see your comment because you forgot the "@ BradleyDOTNet", sorry for the lateness of this response. – BradleyDotNET Jun 19 '14 at 15:58
  • @swiss_programmer, the links are in the "In this section" section (below where it talks about "classic.xaml). – BradleyDotNET Jun 19 '14 at 15:59

2 Answers2

2

They are freely available on MSDN. The "directory" page can be found at:

http://msdn.microsoft.com/en-us/library/aa970773(v=vs.110).aspx

I realize this is a link-only answer, but the answer really is a link...

Currently, googling "WPF Control templates" shows the linked article as the second result. If the link changes, the same search may yield good results.

BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117
  • I was given a link before and it was to some custom (purple) controls. The real stuff was nowhere to be found. I will follow your link, though. –  Jun 18 '14 at 00:31
2

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();
}
EKrueger
  • 730
  • 8
  • 20