WPFwiki, wpf, wiki, .net 3.0, windows presentation foundation, FAQ, free resources, solution, development, microsoft Home of the world's largest WPF FAQ
Edit

Category

Data Binding

Edit

Question

What is the difference between a "{Binding ...}" and a "{TemplateBinding ... }"?

Edit

Answer

Binding is the most typical and versatile option of the two. TemplateBinding provides much fewer options than Binding and is applicable only in the context of a Template (such as DataTemplates and ControlTemplates).

In fact, one can say that TemplateBinding is the equivalent of a Binding on which the RelativeSource property has been set to RelativeSource.TemplatedParent.

Example:

<Control property="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>


While TemplateBinding has a much more friendly syntax than Binding, using TemplateBinding has limitations.

One such limitation is that while using TemplateBinding, it is not possible to change the Mode and the UpdateSourceTrigger of the underlying binding (using the target property's default value for Mode and UpdateSourceTrigger).

Edit

Keywords

binding, templatebinding, updatesourcetrigger, mode

All content is Copyright ©2007 Xceed Software Inc. unless otherwise indicated. See the Terms of Service. Contributors must read and agree to the Contribution Policy. WPFwiki is brought to you by Xceed, makers of the powerful yet free Xceed DataGrid for WPF.