.NET 4 control default templates without Blend

血红的双手。 提交于 2019-12-04 22:09:09

问题


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?


回答1:


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.




回答2:


here is the link from zebi for .Net4.0.



来源:https://stackoverflow.com/questions/7143698/net-4-control-default-templates-without-blend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!