Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Control.Template Property

Gets or sets a control template.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public ControlTemplate Template { get; set; }
/** @property */
public ControlTemplate get_Template ()

/** @property */
public void set_Template (ControlTemplate value)

public function get Template () : ControlTemplate

public function set Template (value : ControlTemplate)

<object>
  <object.Template>
    <ControlTemplate .../>
  </object.Template>
</object>

Property Value

A Template.

The control author defines the default control template and the application author can override the ControlTemplate to redefine the visual tree of the control. See ControlTemplate Examples for information and examples of how to change the visual tree of existing controls.

A ControlTemplate is intended to be a self-contained unit of implementation detail that is invisible to outside users and objects, including Style objects. The only way to manipulate the content of the control template is from within the same control template.

The following example shows how to create a control template and use it with a button control.

<ControlTemplate x:Key="template1">
  <TextBlock Text="Control Template" FontSize="12" FontWeight="Bold" TextWrapping="Wrap">
  </TextBlock>  
</ControlTemplate>

<Button Name="btn12">
      <Control Template="{StaticResource template1}"/>
</Button>

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.