Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can i find the default WPF Control templates?

As per this MSDN link,

There is no way to replace only part of the visual tree of a control; to change the visual tree of a control you must set the Template property of the control to its new and complete ControlTemplate

.

I am trying to disable the click behaviour of GridViewColumnHeader ( I need to remove some triggers in the original control template), but i am not able to find the native "ColumnHeaderContainerStyle". All those i have found seem to have already done some customization and it is being difficult to get the original look and feel.

Can someone please suggest me how/where can i get the original control templates as defined in the native WPF controls?

Thanks for your interest.

like image 895
Manish Basantani Avatar asked Aug 23 '10 14:08

Manish Basantani


People also ask

How can I find WPF controls by name or type?

FindName method of FrameworkElement class is used to find elements or controls by their Name properties. This article shows how to find controls on a Window by name. FindName method of FrameworkElement class is used to find elements or controls by their Name properties.

What is control template in WPF?

The ControlTemplate contains the tree of elements that define the desired look. After you define a ControlTemplate you can attach it to any Control or Page by setting it's TemplateProperty. In this example I am also showing you how to use Triggers with ControlTemplate.

How do I edit a WPF control template?

Right-click the desired control and select Edit Template in the context menu. Click Edit a Copy as shown in Figure 3. In the Create Style Resource dialog, select one of the following options: To extract the style with the default control template in a specified document with a resource key.


2 Answers

In Visual Studio 2015 (at least) you can right click the control in the XAML designer and select "Edit Style->Edit a Copy" to view and edit the default template for a control. Much easier than cracking open Blend, downloading a style viewer, or searching the web.

like image 132
John Stritenberger Avatar answered Oct 07 '22 01:10

John Stritenberger


You can find the templates for all themes at Microsoft Docs.

Furthermore, there are several tools out there which can read the styles from an assembly.
For example, you could use Style Snooper.
However, for your scenario (getting the built-in templates), the above documentation link should be the easiest.

like image 39
gehho Avatar answered Oct 07 '22 00:10

gehho