Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 4 control default templates without Blend

How do people find the default templates of .NET controls when they can't use Expression Blend?

So far, when I needed the templates for WPF controls I went to the WPF project page on Codeplex, browsed the source code and usually found the default templates in "Generic.xaml" files.

But now I am looking for the default template for the "Frame" control. I can't find it on Codeplex, and I don't see it either in the .NET framework source provided by MS (XAML files are not provided, only .cs files).

The Style Snooper tool gives a default template but it seems reverse-engineered (unnecessary lengthy and referencing internal classes) rather than being the original clean definition.

So, how do poor people get those templates?

like image 562
Thibault Avatar asked Aug 22 '11 06:08

Thibault


Video Answer


1 Answers

1) you can get default template and seriallize it to file.

var resource = Application.Current.FindResource(typeof(Control_Under_Interest));
using (XmlTextWriter writer = new XmlTextWriter(file_name, System.Text.Encoding.UTF8))
{
    writer.Formatting = Formatting.Indented;
    XamlWriter.Save(resource, writer);
}

2) Reflector with Baml Viewer may be used to get resources dictionaries from assemblies.

3) dotPeek 1.1 supports BAML disassembling.

like image 82
Yuriy Zanichkovskyy Avatar answered Oct 14 '22 08:10

Yuriy Zanichkovskyy