How to grab WPF 4.0 control default templates? [duplicate]
Asked Answered
E

6

10

I have been using Expression Blend to copy the default templates for WPF 4.0 controls. I am writing a CodeProject article on extending WPF controls, and I would like to recommend a free tool as an alternative. What would you suggest? Thanks for your help.

Emotion answered 19/8, 2010 at 21:24 Comment(0)
C
5

In previous versions of WPF the styles were available at this MSDN link. You can try changing to Older versions, to see the download links. Unfortunately, this hasn't been updated for .NET 4.0 yet.

Until that happens, if ever you can use Reflector with the BamlViewer plugin. Once you have that installed, you'd open one of these assemblies using Open Cache:

  1. PresentationFramework.Aero
  2. PresentationFramework.Classic
  3. PresentationFramework.Luna
  4. PresentationFramework.Royale

Make sure to select the 4.0.0.0 versions. Then expand the assembly and associated Resources nodes. Selected the resource entry and press the Space bar to view the Disassembler. Then you can see the BAML files, which you can view the XAML using BamlViewer. The only downside is you lose the original formatting.

EDIT:

The .NET 4 Styles can be downloaded from here. More specifically, the Default WPF Themes link in the second paragraph. Alternatively, you can drill into specific controls to see a Style example.

Cremate answered 20/8, 2010 at 0:35 Comment(0)
B
8

XamlPadX has a button "Open/Close Styles Window" that shows little dialog which allows you to view the Styles.

alt text

Brood answered 19/8, 2010 at 21:34 Comment(1)
Unfortunately, XamlPadX hasn't been updated for WPF 4.0. It doesn't have any of the new controls, such as the Calendar.Emotion
C
5

In previous versions of WPF the styles were available at this MSDN link. You can try changing to Older versions, to see the download links. Unfortunately, this hasn't been updated for .NET 4.0 yet.

Until that happens, if ever you can use Reflector with the BamlViewer plugin. Once you have that installed, you'd open one of these assemblies using Open Cache:

  1. PresentationFramework.Aero
  2. PresentationFramework.Classic
  3. PresentationFramework.Luna
  4. PresentationFramework.Royale

Make sure to select the 4.0.0.0 versions. Then expand the assembly and associated Resources nodes. Selected the resource entry and press the Space bar to view the Disassembler. Then you can see the BAML files, which you can view the XAML using BamlViewer. The only downside is you lose the original formatting.

EDIT:

The .NET 4 Styles can be downloaded from here. More specifically, the Default WPF Themes link in the second paragraph. Alternatively, you can drill into specific controls to see a Style example.

Cremate answered 20/8, 2010 at 0:35 Comment(0)
M
3

MSDN lists them for Silverlight controls:
http://msdn.microsoft.com/en-us/library/cc278069(VS.95).aspx

But I can't find a similar listing for WPF controls. The corresponding WPF page is this and mysteriously absent a template listing:
http://msdn.microsoft.com/en-us/library/ms753328.aspx

Regardless, it's easy to grab the templates. From here:
http://msdn.microsoft.com/en-us/magazine/cc163497.aspx#S1

Control ctrl = GetControl(); // any type deriving from Control

XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = new string(' ', 4);
settings.NewLineOnAttributes = true;
StringBuilder strbuild = new StringBuilder();
XmlWriter xmlwrite = XmlWriter.Create(strbuild, settings);

// Save the template to the XAML writer
XamlWriter.Save(ctrl.Template, xmlwrite);
Marquetry answered 19/8, 2010 at 21:33 Comment(0)
E
3

Control templates for WPF 4.0 controls can now be found here.

However, You can extend or override a control template without having to reproduce the original, by using the Style.BasedOn property. It is explained in this blog post.

Emotion answered 11/9, 2010 at 19:49 Comment(0)
C
0

Please take a look at this article: http://eggheadcafe.com/tutorials/aspnet/d1ad0a33-d815-4083-8e97-c234fd661095/wpf-controls-default-style-or-template-by-extending-the-wpf-designer-in-visual-studio-2010.aspx. I've extended the WPF designer to include getting the default style or template through a context menu of the selected control. Just build the Visual Studio solution and set the registry entries to load the metadata. The downside is that XAML formatting is not like that of Expression Blend.

Chalcis answered 19/8, 2010 at 23:24 Comment(0)
B
0

or install Expression Blend (trial) and go to below location:

C:\Program Files\Microsoft Expression\Blend 4\SystemThemes\Wpf
Bellaude answered 13/6, 2012 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.