Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Control Class
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Control Class

Updated: November 2007

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/xaml/presentation

Visual Basic (Declaration)
Public Class Control _
    Inherits FrameworkElement
Visual Basic (Usage)
Dim instance As Control
C#
public class Control : FrameworkElement
Visual C++
public ref class Control : public FrameworkElement
J#
public class Control extends FrameworkElement
JScript
public class Control extends FrameworkElement
XAML Object Element Usage
<Control .../>

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

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 Vista

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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker