更新:
2008 年 7 月
为 Windows Presentation Foundation (WPF) 元素提供 WPF 框架级属性集、事件集和方法集。此类表示附带的 WPF 框架级实现,它是基于由 UIElement 定义的 WPF 核心级 API 构建的。
命名空间:
System.Windows 程序集:
PresentationFramework(在 PresentationFramework.dll 中)
用于 XAML 的 XMLNS:http://schemas.microsoft.com/winfx/xaml/presentation
<RuntimeNamePropertyAttribute("Name")> _
<StyleTypedPropertyAttribute(Property := "FocusVisualStyle", StyleTargetType := GetType(Control))> _
<XmlLangPropertyAttribute("Language")> _
Public Class FrameworkElement _
Inherits UIElement _
Implements IFrameworkInputElement, IInputElement, ISupportInitialize
Dim instance As FrameworkElement
[RuntimeNamePropertyAttribute("Name")]
[StyleTypedPropertyAttribute(Property = "FocusVisualStyle", StyleTargetType = typeof(Control))]
[XmlLangPropertyAttribute("Language")]
public class FrameworkElement : UIElement,
IFrameworkInputElement, IInputElement, ISupportInitialize
[RuntimeNamePropertyAttribute(L"Name")]
[StyleTypedPropertyAttribute(Property = L"FocusVisualStyle", StyleTargetType = typeof(Control))]
[XmlLangPropertyAttribute(L"Language")]
public ref class FrameworkElement : public UIElement,
IFrameworkInputElement, IInputElement, ISupportInitialize
/** @attribute RuntimeNamePropertyAttribute("Name") */
/** @attribute StyleTypedPropertyAttribute(Property = "FocusVisualStyle", StyleTargetType = Control) */
/** @attribute XmlLangPropertyAttribute("Language") */
public class FrameworkElement extends UIElement implements IFrameworkInputElement,
IInputElement, ISupportInitialize
public class FrameworkElement extends UIElement implements IFrameworkInputElement, IInputElement, ISupportInitialize
FrameworkElement 是 WPF 框架级元素类与 WPF 核心级 UIElement 表示服务集之间的连接点。有关这些概念的更多信息,请参见 WPF 体系结构。
FrameworkElement 扩展了 UIElement 并添加了下列功能:
布局系统定义:FrameworkElement 为已定义为 UIElement 中的虚拟成员的某些方法提供特定 WPF 框架级实现。最值得注意的是,FrameworkElement 会密封某些 WPF 核心级布局重写,而改为提供派生类应重写的 WPF 框架级等效布局重写。例如,FrameworkElement 密封 ArrangeCore 但提供 ArrangeOverride。这些更改表明:在 WPF 框架级别上,存在可以呈现任何 FrameworkElement 派生类的完整布局系统。在 WPF 核心级别上,存在能够基于布局解决方案构建常规 WPF 的某些成员,但并未定义布局系统的实际引擎。有关更多信息,请参见布局系统。
逻辑树:常规 WPF 编程模型通常用元素树表示。在 FrameworkElement 级别上,不仅支持将元素树表示为逻辑树,同时还支持在标记中定义此树。但请注意,FrameworkElement 特意未定义内容模型,并将这一责任留给了派生类。有关更多信息,请参见 WPF 中的树。
对象生存期事件:通常,了解元素何时初始化(调用构造函数)或元素何时首次加载到逻辑树非常有用。FrameworkElement 定义了多个与对象生存期有关的事件,这些事件为涉及元素的代码隐藏操作(如添加更多子元素)提供了有用的挂钩。有关更多信息,请参见对象生存期事件。
数据绑定和动态资源引用的支持:数据绑定和资源的属性级支持由 DependencyProperty 类实现并体现在属性系统中,但对存储为 Expression(作为数据绑定和动态资源基础的编程结构)的成员值进行解析的功能则由 FrameworkElement 来实现。有关更多信息,请参见数据绑定概述和资源概述。
样式:FrameworkElement 可定义 Style 属性。不过,FrameworkElement 还不能定义模板支持,也不支持修饰器。这些功能可由控件类(如 Control 和 ContentControl)引入。
更多动画支持:在 WPF 核心级别上已定义了一些动画支持,而 FrameworkElement 通过实现 BeginStoryboard 和相关成员对此进行了扩展。
正如在类层次结构中看到的那样,许多 WPF 类都是从 FrameworkElement 派生而来的,其方式可以是直接派生,也可以是通过中间基类(如 Panel 或 Control)派生。
如果要将 FrameworkElement 用作基类,需要先检查现有派生类。FrameworkElement 虽然提供了对一些基本方案的支持,但如果要构建用于在可扩展应用程序标记语言 (XAML) 中创建用户界面 (UI) 的块,还缺少一些“元素”所需的功能。例如,FrameworkElement 未定义任何真正的内容模型;作为一个基类,FrameworkElement 未定义可创建 XAML 子元素的属性。尤其是,您可能需要查看 Control 和 ContentControl。
System..::.Object
System.Windows.Threading..::.DispatcherObject
System.Windows..::.DependencyObject
System.Windows.Media..::.Visual
System.Windows..::.UIElement
System.Windows..::.FrameworkElement
Microsoft.Windows.Themes..::.BulletChrome
Microsoft.Windows.Themes..::.BulletChrome
Microsoft.Windows.Themes..::.BulletChrome
Microsoft.Windows.Themes..::.ScrollChrome
Microsoft.Windows.Themes..::.ScrollChrome
Microsoft.Windows.Themes..::.ScrollChrome
System.Windows.Controls..::.AccessText
System.Windows.Controls..::.AdornedElementPlaceholder
System.Windows.Controls..::.ContentPresenter
System.Windows.Controls..::.Control
System.Windows.Controls..::.Decorator
System.Windows.Controls..::.Image
System.Windows.Controls..::.InkCanvas
System.Windows.Controls..::.ItemsPresenter
System.Windows.Controls..::.MediaElement
System.Windows.Controls..::.Page
System.Windows.Controls..::.Panel
System.Windows.Controls.Primitives..::.DocumentPageView
System.Windows.Controls.Primitives..::.GridViewRowPresenterBase
System.Windows.Controls.Primitives..::.Popup
System.Windows.Controls.Primitives..::.TickBar
System.Windows.Controls.Primitives..::.Track
System.Windows.Controls..::.TextBlock
System.Windows.Controls..::.ToolBarTray
System.Windows.Controls..::.Viewport3D
System.Windows.Documents..::.Adorner
System.Windows.Documents..::.AdornerLayer
System.Windows.Documents..::.DocumentReference
System.Windows.Documents..::.FixedPage
System.Windows.Documents..::.Glyphs
System.Windows.Documents..::.PageContent
System.Windows.Interop..::.HwndHost
System.Windows.Shapes..::.Shape
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
.NET Framework
受以下版本支持:3.5、3.0
参考
其他资源