TemplatedParent Property

RelativeSource.TemplatedParent Property


Gets a static value that is used to return a RelativeSource constructed for the TemplatedParent mode.

Namespace:   System.Windows.Data
Assembly:  PresentationFramework (in PresentationFramework.dll)

public static RelativeSource TemplatedParent { get; }

Three of the four RelativeSourceMode values, PreviousData, Self, or TemplatedParent, can produce a RelativeSource that is wholly static, containing no unique private values. All uses of the static property can share the same object, eliminating the need to allocate separate objects for each use. Therefore, using the static property reduces memory usage.

The following example shows the Style definition of a custom control called NumericUpDown. The Text property of the TextBlock is bound to the Value of the object that is the TemplatedParent, which is the NumericUpDown control that this Style is applied to in this case.

For the complete sample, see NumericUpDown Custom Control with Theme and UI Automation Support Sample.

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft