Questions tagged [controltemplate]

The ControlTemplate allows you to specify the visual structure of a control. The control author can define the default ControlTemplate and the application author can override the ControlTemplate to reconstruct the visual structure of the control.

The ControlTemplate allows you to specify the visual structure of a control. The control author can define the default ControlTemplate and the application author can override the ControlTemplate to reconstruct the visual structure of the control.

A ControlTemplate is a powerful WPF mechanism to (re)define the visual layout of any control. The template replaces the control's visual tree with the content of the template. Control templates often appear in WPF themes, where the visual layout of controls such as buttons are applied globally or regionally.

1117 questions
251
votes
6 answers

ResourceDictionary in a separate assembly

I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in multiple separate applications. I could add them to the applications' assemblies, but it's better if I compile these resources in one single…
Gus Cavalcanti
  • 10,127
  • 22
  • 68
  • 102
214
votes
7 answers

Difference between Control Template and DataTemplate in WPF

What is difference between a ControlTemplate and a DataTemplate in WPF?
Firoz
  • 6,636
  • 10
  • 35
  • 56
97
votes
5 answers

How to create a WPF Window without a border that can be resized via a grip only?

If you set ResizeMode="CanResizeWithGrip" on a WPF Window then a resize grip is shown in the lower right corner, as below: If you set WindowStyle="None" as well the title bar disappears but the grey bevelled edge remains until you set…
Drew Noakes
  • 266,361
  • 143
  • 616
  • 705
45
votes
2 answers

In WPF, why doesn't TemplateBinding work where Binding does?

Ok... this is leaving me scratching my head. I have two WPF controls--one's a user control and the other's a custom control. Let's call them UserFoo and CustomFoo. In the control template for CustomFoo, I use an instance of UserFoo which is a…
Mark A. Donohoe
  • 23,825
  • 17
  • 116
  • 235
45
votes
5 answers

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…
Manish Basantani
  • 15,105
  • 22
  • 65
  • 96
40
votes
8 answers

ControlTemplate for existing controls in WPF

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.
Sugirthini
40
votes
2 answers

WPF ControlTemplate vs UserControl

I've recently made an UserControl, which took quite a long time, because I had to work with custom Dependency Properties and so on... Anyways, it was just a bunch of 3 controls: TextBox, Popup with Hierarchical Tree. Now I realized I could probably…
PaN1C_Showt1Me
  • 11,483
  • 28
  • 90
  • 148
35
votes
4 answers

Replace part of default template in WPF

is there any "best practice" way to replace a part of the default template. The current use case is a treeview. As default, the treeview has this small triangle shapes to expand and collapse. I know how to replace these if I replace the whole…
Christian Ruppert
  • 3,549
  • 5
  • 43
  • 72
32
votes
4 answers

WPF ControlTemplate: How to provide a default value for TemplateBinding?

I am writing a WPF control that subclasses a Button. I then provide a default style in Themes\generic.xaml, that looks like this (simplified):