Control Class

Represents the base class for user interface (UI) elements that use a ControlTemplate to define their appearance. 

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public class Control extends FrameworkElement

The Control class is the base class for many of the controls you add to an application. The Control class defines very little behavior; while it is possible to add a Control to your application, it is far more common to add a control that inherits from Control, such as a Button or ListBox.

The Template property, which is a ControlTemplate, specifies the appearance of the Control. If you want to change the appearance of a control but retain its functionality, you should consider creating a new ControlTemplate instead of creating a new class. For more information, see Styling and Templating.

If you want to create a control with custom behavior as well as allow others to customize its appearance, your control can inherit from the Control class and define a ControlTemplate. If you want to extend the behavior of an existing control, you can inherit from a class that inherits from Control.

A Control that does not have a ControlTemplate is not visible in your application, and setting the following properties has no effect unless the ControlTemplate references them explicitly:

A common way to use these properties is to bind an element in the ControlTemplate to the property. For example, if you want your control to change color according to the value of the Background property, you can bind some property of an element in the ControlTemplate to the Background. Use the TemplateBinding Markup Extension to bind properties on a control to an element in the ControlTemplate.

Control overrides the metadata of the Focusable property and sets its default to true. For more information, see Dependency Properties Overview

System.Object
  System.Windows.Threading.DispatcherObject
    System.Windows.DependencyObject
      System.Windows.Media.Visual
        System.Windows.UIElement
          System.Windows.FrameworkElement
            System.Windows.Controls.Control
              System.Windows.Controls.ContentControl
              System.Windows.Controls.FlowDocumentReader
              System.Windows.Controls.FlowDocumentScrollViewer
              System.Windows.Controls.ItemsControl
              System.Windows.Controls.PasswordBox
              System.Windows.Controls.Primitives.DocumentViewerBase
              System.Windows.Controls.Primitives.RangeBase
              System.Windows.Controls.Primitives.ResizeGrip
              System.Windows.Controls.Primitives.TextBoxBase
              System.Windows.Controls.Primitives.Thumb
              System.Windows.Controls.Separator
              System.Windows.Controls.StickyNoteControl

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft