Control Class

Definition

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

public class Control : System.Windows.FrameworkElement
Inheritance
Derived
System.Activities.Presentation.Toolbox.ToolboxControl
System.Windows.Controls.Calendar
System.Windows.Controls.ContentControl
System.Windows.Controls.DataGridRow
System.Windows.Controls.DatePicker
More…

Inherited Members

System.Object

System.Windows.DependencyObject

System.Windows.FrameworkElement

System.Windows.Media.Visual

System.Windows.Threading.DispatcherObject

System.Windows.UIElement

Remarks

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

Constructors

Control()

Initializes a new instance of the Control class.

Fields

BackgroundProperty

Identifies the Background dependency property.

BorderBrushProperty

Identifies the BorderBrush dependency property.

BorderThicknessProperty

Identifies the BorderThickness dependency property.

FontFamilyProperty

Identifies the FontFamily dependency property.

FontSizeProperty

Identifies the FontSize dependency property.

FontStretchProperty

Identifies the FontStretch dependency property.

FontStyleProperty

Identifies the FontStyle dependency property.

FontWeightProperty

Identifies the FontWeight dependency property.

ForegroundProperty

Identifies the Foreground dependency property.

HorizontalContentAlignmentProperty

Identifies the HorizontalContentAlignment dependency property.

IsTabStopProperty

Identifies the IsTabStop dependency property.

MouseDoubleClickEvent

Identifies the MouseDoubleClick routed event.

PaddingProperty

Identifies the Padding dependency property.

PreviewMouseDoubleClickEvent

Identifies the PreviewMouseDoubleClick routed event.

TabIndexProperty

Identifies the TabIndex dependency property.

TemplateProperty

Identifies the Template dependency property.

VerticalContentAlignmentProperty

Identifies the VerticalContentAlignment dependency property.

Properties

Background

Gets or sets a brush that describes the background of a control.

BorderBrush

Gets or sets a brush that describes the border background of a control.

BorderThickness

Gets or sets the border thickness of a control.

FontFamily

Gets or sets the font family of the control.

FontSize

Gets or sets the font size.

FontStretch

Gets or sets the degree to which a font is condensed or expanded on the screen.

FontStyle

Gets or sets the font style.

FontWeight

Gets or sets the weight or thickness of the specified font.

Foreground

Gets or sets a brush that describes the foreground color.

HandlesScrolling

Gets a value that indicates whether a control supports scrolling.

HorizontalContentAlignment

Gets or sets the horizontal alignment of the control's content.

IsTabStop

Gets or sets a value that indicates whether a control is included in tab navigation.

Padding

Gets or sets the padding inside a control.

TabIndex

Gets or sets a value that determines the order in which elements receive focus when the user navigates through controls by using the TAB key.

Template

Gets or sets a control template.

VerticalContentAlignment

Gets or sets the vertical alignment of the control's content.

Methods

ArrangeOverride(Size)

Called to arrange and size the content of a Control object.

MeasureOverride(Size)

Called to remeasure a control.

OnMouseDoubleClick(MouseButtonEventArgs)

Raises the MouseDoubleClick routed event.

OnPreviewMouseDoubleClick(MouseButtonEventArgs)

Raises the PreviewMouseDoubleClick routed event.

OnTemplateChanged(ControlTemplate, ControlTemplate)

Called whenever the control's template changes.

ToString()

Returns the string representation of a Control object.

Events

MouseDoubleClick

Occurs when a mouse button is clicked two or more times.

PreviewMouseDoubleClick

Occurs when a user clicks the mouse button two or more times.