Specifies the visual structure and behavioral aspects of a Control that can be shared across multiple instances of the control.
Assembly: PresentationFramework (in PresentationFramework.dll)
Gets a value that indicates whether this template has optimized content.(Inherited from FrameworkTemplate.)
Gets a value that indicates whether this object is in an immutable state so it cannot be changed.(Inherited from FrameworkTemplate.)
Gets or sets the collection of resources that can be used within the scope of this template.(Inherited from FrameworkTemplate.)
Gets or sets the type for which thisis intended.
Gets or sets a reference to the object that records or plays the XAML nodes for the template when the template is defined or applied by a writer.(Inherited from FrameworkTemplate.)
Gets a collection of TriggerBase objects that apply property changes or perform actions based on specified conditions.
Gets or sets the root node of the template.(Inherited from FrameworkTemplate.)
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.)
Finds the element associated with the specified name defined within this template.(Inherited from FrameworkTemplate.)
Serves as the default hash function. (Inherited from Object.)
Loads the content of the template as an instance of an object and returns the root element of the content.(Inherited from FrameworkTemplate.)
Registers a new name/object pair into the current name scope.(Inherited from FrameworkTemplate.)
Locks the template so it cannot be changed.(Inherited from FrameworkTemplate.)
Returns a string that represents the current object.(Inherited from Object.)
Removes a name/object mapping from the XAML namescope.(Inherited from FrameworkTemplate.)
Checks the templated parent against a set of rules.(Overrides FrameworkTemplate.ValidateTemplatedParent(FrameworkElement).)
This API supports the product infrastructure and is not intended to be used directly from your code. Returns an object that has the provided identifying name. (Inherited from FrameworkTemplate.)
Queries whether a specified ambient property is available in the current scope.(Inherited from FrameworkTemplate.)
Theallows you to specify the visual structure of a control. The control author can define the default and the application author can override the to reconstruct the visual structure of the control.
Control templating is one of the many features offered by the WPF styling and templating model. The styling and templating model provides you with such great flexibility that in many cases you do not need to write your own controls. If you are an application author that wants to change the visualization of your control or to replace the Styling and Templating topic for examples and an in-depth discussion.of an existing control, see the
If you are writing your own control, see "Create a Custom Control" in the Control Authoring Overview.
Ais intended to be a self-contained unit of implementation detail that is invisible to outside users and objects, including styles. The only way to manipulate the content of the control template is from within the same control template.
Object element foror a derived class.
A single XAML element as the immediate child of the(or a derived class). Templates must have a single root node. In order to generate a useful template, the element chosen as VisualTreeRootNode is expected to support a content model of its own, often a model that supports multiple child elements.
One or more elements that complete the intended template. If the element chosen as VisualTreeRootNode only supports a single child, then there can only be one element declared as VisualTreeNodeContents. It is also possible (though uncommon) to provide text content if the chosen VisualTreeRootNode supports a text content property.
Legacy Code Example
When you set the Template property of a Control to a new as in the above example, you are replacing the entire template. What the Button looks like when it is in focus or pressed is all part of the default appearance of the button that you are replacing. Therefore, depending on your needs, you may want to put in your definition what your button should look like when it is pressed, and so on, as in the following example:Code snippet is not found. Confirm that the code snippet name 'ControlTemplateExamples' is correct.
Note that this example references resources that are not shown here. For the complete sample, see Styling with ControlTemplates Sample. That sample provides examples of control templates for many controls and is the best way for you to get started with creating control templates.
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.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.