更新:2007 年 11 月
命名空间:
System.Windows.Controls 程序集:
PresentationFramework(在 PresentationFramework.dll 中)
用于 XAML 的 XMLNS:http://schemas.microsoft.com/winfx/xaml/presentation
Public Class Control _
Inherits FrameworkElement
public class Control : FrameworkElement
public ref class Control : public FrameworkElement
public class Control extends FrameworkElement
public class Control extends FrameworkElement
Control 类是添加到应用程序中的许多控件的基类。Control 类很少定义行为,但可以将 Control 添加到应用程序中,添加继承自 Control 的控件(如 Button 或 ListBox)的情况更为常见。
Template 属性是一个 ControlTemplate,可以指定 Control 的外观。如果要更改控件的外观并保留其功能,应考虑创建新的 ControlTemplate 而不是创建新的类。有关更多信息,请参见样式设置和模板化。
如果要创建具有自定义行为的控件并允许其他人自定义控件的外观,则所创建的控件可以从 Control 类继承并定义一个 ControlTemplate。如果要扩展现有控件的行为,可以从继承自 Control 的类继承。
不具有 ControlTemplate 的 Control 在应用程序中不可见,并且设置下列属性不会起任何作用,除非 ControlTemplate 显式引用它们:
使用这些属性的常见方法是将 ControlTemplate 中的某个元素与属性绑定。例如,如果希望根据 Background 属性的值更改控件的颜色,可以将 ControlTemplate 中的某个元素的属性绑定到 Background。使用 TemplateBinding 标记扩展 将控件上的属性绑定到 ControlTemplate 中的某个元素。
Control 重写 Focusable 属性的元数据,并将其默认值设置为 true。有关更多信息,请参见依赖项属性概述
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
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
.NET Framework
受以下版本支持:3.5、3.0
参考
其他资源