Implements a markup extension that supports the binding between the value of a property in a template and the value of some other exposed property on the templated control.
Assembly: PresentationFramework (in PresentationFramework.dll)
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
Returns a string that represents the current object.(Inherited from Object.)
You use TemplateBinding in template to bind to a value on the control the template is applied to. A TemplateBinding is more efficient than a Binding but it has less functionality. Using a TemplateBinding is equivalent to using a Binding with the RelativeSource property set to RelativeSource.TemplatedParent.
Legacy Code Example
The following example shows a ControlTemplate that defines a ListBox that is horizontal and has rounded corners. The TemplateBinding indicates that the Background of the Border should be synchronized with the Background value that is set on the ListBox. You use TemplateBinding in your ControlTemplate when you want to give the user of your control the control over the values of certain properties. For a discussion of this example, see Styling and Templating.Code snippet is not found. Confirm that the code snippet name 'StylingIntroSample' is correct.
The following example shows the ControlTemplate of the Label control. The HorizontalAlignment and VerticalAlignment properties are bound to the values of the HorizontalContentAlignment and VerticalContentAlignment properties of the Label control that this ControlTemplate is applied to.Code snippet is not found. Confirm that the code snippet name 'ControlTemplateExamples' is correct.
Available since 3.0
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.