Where can i find the default WPF Control templates?

Viewed 27234

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.

6 Answers

As this blog post says, use this code (call it once) and read the output file (defaultTemplate.xml):

public static void SaveDefaultTemplate()
{
    var control = Application.Current.FindResource(typeof(ButtonSpinner));
    using (XmlWriter writer = XmlWriter.Create(@"defaultTemplate.xml"))
    {
        XamlWriter.Save(control, writer);
    }
}

In my opinion this is the best method. Some elements like DataGridCell are not extractable through Visual Studio tweak: Properties>Template>Convert to New Resource... because you can't explicitly define any DataGridCell.

for vs2022 community : C:\Program Files\Microsoft Visual Studio\2022\Community\DesignTools\SystemThemes\

Related