views:

620

answers:

5

How to get existing control's controltemplate in WPF in XAML format(visual tree)? This is to help to create new controltemplate with the help of existing template.

A: 

You can use a tool like ShowMeTheTemplate

Thomas Levesque
Is there a code to get it in XAML format?(like view the visual tree in tree format)
Sugirthini
yes, since this tool does it... you can look at the code, it's provided in the zip file
Thomas Levesque
+3  A: 
Drew Noakes
+1  A: 

If you have Expression Blend you can:

  1. Drag the control onto the design surface
  2. Right click the control and choose Edit Template -> Edit Copy

When you do this, Blend will extract the base template from the control and explicitly declare it within document/application as a resource which you can then edit to your liking. You can do this for any control.

Drew Marsh
+1  A: 

Please look at MSDN's ControlTemplate Examples they have given all controls in there.

However you can also extend existing style without redefining evrything by using "BasedOn" attribute.

Akash Kava
A: 

The book "Pro WPF in C# 2008", by Matthew MacDonald, includes a Control Template browser in Chapter 15. I believe you can simply download the sample code from the Apress web site.

David Veeneman