Visual Visual Visual Visual Class

定义

为 WPF 中的呈现提供支持,其中包括命中测试、坐标转换和边界框计算。Provides rendering support in WPF, which includes hit testing, coordinate transformation, and bounding box calculations.

public ref class Visual abstract : System::Windows::DependencyObject
public abstract class Visual : System.Windows.DependencyObject
type Visual = class
    inherit DependencyObject
    interface DUCE.IResource
Public MustInherit Class Visual
Inherits DependencyObject
继承
派生

注解

类是每个FrameworkElement对象派生自的基本抽象。 VisualThe Visual class is the basic abstraction from which every FrameworkElement object derives. 它还用作在中WPFWPF编写新控件的入口点, 在许多方面, 可被视为Win32Win32应用程序模型中的窗口句柄 (HWND) 的等效项。It also serves as the entry point for writing new controls in WPFWPF, and in many ways can be thought of as an equivalent of a window handle (HWND) in the Win32Win32 application model.

对象是核心WPFWPF对象, 其主要角色是提供呈现支持。 VisualThe Visual object is a core WPFWPF object, whose primary role is to provide rendering support. 用户界面控件 ( Button例如和TextBox) 从Visual类派生, 并使用Visual定义的属性来保存其呈现数据。User interface controls, such as Button and TextBox, derive from the Visual class, and use the Visual defined properties for persisting their rendering data. Visual对象提供对以下各项的支持:The Visual object provides support for the following:

  • 输出显示:呈现视觉对象的持久、序列化的绘图内容。Output display: Rendering the persisted, serialized drawing content of a visual.

  • 转换:针对视觉对象执行转换。Transformations: Performing transformations on a visual.

  • 剪裁:为视觉对象提供剪裁区域支持。Clipping: Providing clipping region support for a visual.

  • 命中测试:确定指定的坐标 (点) 或几何图形是否包含在视觉对象的边界内。Hit testing: Determining whether a specified coordinate (point) or geometry is contained within the bounds of a visual.

  • 边框计算:确定视觉对象的边框。Bounding box calculations: Determining the bounding rectangle of a visual.

Visual结构上讲, 对象不支持其他应用程序开发要求/ WPFWPF功能, 这些要求/功能不会立即与呈现相关, 如以下内容所示:Architecturally, the Visual object does not include support for other application development requirements / WPFWPF features that are not immediately related to its rendering, such as the following:

  • 事件处理Event handling

  • 布局Layout

  • 样式Styles

  • 数据绑定Data binding

  • 全球化Globalization

Visual作为可从中派生更多类的公共抽象类提供。Visual is provided as a public abstract class from which further classes can be derived. 下图显示了在WPFWPF体系结构中定义的现有视觉对象的层次结构。The following illustration shows the hierarchy of the existing visual objects that are defined in the WPFWPF architecture.

从视觉对象派生的类的关系图Diagram of classes derived from the Visual object
视觉对象类层次结构Visual class hierarchy

在某些情况下, 在Visual派生UIElement类中, 定义为受保护的成员将公开为更易于访问的成员, 具有类似的名称。In some cases, members that are defined as protected in Visual are exposed as more readily accessible members with similar names in the derived UIElement class.

有关详细信息,请参阅 WPF 图形呈现概述For more information, see WPF Graphics Rendering Overview.

Visual具有有限的级别数。A Visual has a limited number of levels. 在 .NET Framework 的以前版本中, 此最大深度为255。In previous versions of the .NET Framework, this maximum depth was 255. 对于在可视化树中具有多个级别的某些布局而言, 此限制不够用。This limit is inadequate for some layouts that have many levels in the visual tree.

.NET Framework 4.NET Framework 4中, 的最大深度Visual为 2047, 这可以实现更多的可视化树。In .NET Framework 4.NET Framework 4, the maximum depth of a Visual is 2047, which enables much deeper visual trees. 在大多数应用程序中, 堆栈空间不足, 无法遍历太多级别, 结果在布局StackOverflowException期间是。In most applications, there is not enough stack space to traverse so many levels, and the result is a StackOverflowException during layout. 对于默认堆栈大小, 如果树深度大约为 800 (相当于大约190个嵌套TreeViewItem对象), 则通常会引发此异常。For the default stack size, this exception is usually thrown when the tree depth is approximately 800, which corresponds to about 190 nested TreeViewItem objects.

如果你的应用程序引发此异常, 并且你需要具有更深入的可视化树, 则可以增加应用程序的堆栈大小。If this exception is thrown by your application and you need to have a deeper visual tree, you can increase the application's stack size. 可以通过在编译时使用/STACK 选项或使用 EDITBIN 实用工具来增加堆栈的大小。You can increase the size of the stack by using the /STACK option at compile time or by using the EDITBIN utility. 增大堆栈大小可能会影响应用程序的性能。Increasing the stack size may affect your application's performance. 有关详细信息, 请参阅Stack 分配EDITBIN 选项For more information, see Stack Allocations and EDITBIN Options.

构造函数

Visual() Visual() Visual() Visual()

为从 Visual 类派生的对象提供基本初始化。Provides the base initialization for objects derived from the Visual class.

属性

DependencyObjectType DependencyObjectType DependencyObjectType DependencyObjectType

获取对此实例的 CLRCLR 类型进行包装的 DependencyObjectTypeGets the DependencyObjectType that wraps the CLRCLR type of this instance.

(Inherited from DependencyObject)
Dispatcher Dispatcher Dispatcher Dispatcher

获取与此 Dispatcher 关联的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

(Inherited from DispatcherObject)
IsSealed IsSealed IsSealed IsSealed

获取一个值,该值指示此实例当前是否为密封的(只读)。Gets a value that indicates whether this instance is currently sealed (read-only).

(Inherited from DependencyObject)
VisualBitmapEffect VisualBitmapEffect VisualBitmapEffect VisualBitmapEffect

获取或设置 BitmapEffectVisual 值。Gets or sets the BitmapEffect value for the Visual.

VisualBitmapEffectInput VisualBitmapEffectInput VisualBitmapEffectInput VisualBitmapEffectInput

获取或设置 BitmapEffectInputVisual 值。Gets or sets the BitmapEffectInput value for the Visual.

VisualBitmapScalingMode VisualBitmapScalingMode VisualBitmapScalingMode VisualBitmapScalingMode

获取或设置 BitmapScalingModeVisualGets or sets the BitmapScalingMode for the Visual.

VisualCacheMode VisualCacheMode VisualCacheMode VisualCacheMode

获取或设置 Visual 的缓存表示形式。Gets or sets a cached representation of the Visual.

VisualChildrenCount VisualChildrenCount VisualChildrenCount VisualChildrenCount

获取 Visual 的子元素数量。Gets the number of child elements for the Visual.

VisualClearTypeHint VisualClearTypeHint VisualClearTypeHint VisualClearTypeHint

获取或设置 ClearTypeHint,它确定在 Visual 中呈现 ClearType 的方式。Gets or sets the ClearTypeHint that determines how ClearType is rendered in the Visual.

VisualClip VisualClip VisualClip VisualClip

获取或设置 Visual 的剪辑区域作为 Geometry 值。Gets or sets the clip region of the Visual as a Geometry value.

VisualEdgeMode VisualEdgeMode VisualEdgeMode VisualEdgeMode

获取或设置 Visual 的边缘模式作为 EdgeMode 值。Gets or sets the edge mode of the Visual as an EdgeMode value.

VisualEffect VisualEffect VisualEffect VisualEffect

获取或设置要应用于 Visual 的位图效果。Gets or sets the bitmap effect to apply to the Visual.

VisualOffset VisualOffset VisualOffset VisualOffset

获取或设置可视对象的偏移量值。Gets or sets the offset value of the visual object.

VisualOpacity VisualOpacity VisualOpacity VisualOpacity

获取或设置 Visual 的不透明度。Gets or sets the opacity of the Visual.

VisualOpacityMask VisualOpacityMask VisualOpacityMask VisualOpacityMask

获取或设置 Brush 值,该值表示 Visual 的不透明蒙板。Gets or sets the Brush value that represents the opacity mask of the Visual.

VisualParent VisualParent VisualParent VisualParent

获取可视对象的可视化树父级。Gets the visual tree parent of the visual object.

VisualScrollableAreaClip VisualScrollableAreaClip VisualScrollableAreaClip VisualScrollableAreaClip

获取或设置 Visual 的剪辑的可滚动区域。Gets or sets a clipped scrollable area for the Visual.

VisualTextHintingMode VisualTextHintingMode VisualTextHintingMode VisualTextHintingMode

获取或设置 VisualTextHintingModeGets or sets the TextHintingMode of the Visual.

VisualTextRenderingMode VisualTextRenderingMode VisualTextRenderingMode VisualTextRenderingMode

获取或设置 VisualTextRenderingModeGets or sets the TextRenderingMode of the Visual.

VisualTransform VisualTransform VisualTransform VisualTransform

获取或设置 TransformVisual 值。Gets or sets the Transform value for the Visual.

VisualXSnappingGuidelines VisualXSnappingGuidelines VisualXSnappingGuidelines VisualXSnappingGuidelines

获取或设置 X 坐标(垂直)准线集合。Gets or sets the x-coordinate (vertical) guideline collection.

VisualYSnappingGuidelines VisualYSnappingGuidelines VisualYSnappingGuidelines VisualYSnappingGuidelines

获取或设置 Y 坐标(水平)准线集合。Gets or sets the y-coordinate (horizontal) guideline collection.

方法

AddVisualChild(Visual) AddVisualChild(Visual) AddVisualChild(Visual) AddVisualChild(Visual)

定义两个可视对象之间的父子关系。Defines the parent-child relationship between two visuals.

CheckAccess() CheckAccess() CheckAccess() CheckAccess()

确定调用线程是否可以访问此 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

清除属性的本地值。Clears the local value of a property. 要清除的属性由 DependencyProperty 标识符指定。The property to be cleared is specified by a DependencyProperty identifier.

(Inherited from DependencyObject)
ClearValue(DependencyPropertyKey) ClearValue(DependencyPropertyKey) ClearValue(DependencyPropertyKey) ClearValue(DependencyPropertyKey)

清除只读属性的本地值。Clears the local value of a read-only property. 要清除的属性由 DependencyPropertyKey 指定。The property to be cleared is specified by a DependencyPropertyKey.

(Inherited from DependencyObject)
CoerceValue(DependencyProperty) CoerceValue(DependencyProperty) CoerceValue(DependencyProperty) CoerceValue(DependencyProperty)

对指定依赖属性的值进行强制。Coerces the value of the specified dependency property. 通过对调用方 DependencyObject 上存在的依赖属性的属性元数据中所指定的任何 CoerceValueCallback 函数进行调用来完成此操作。This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.

(Inherited from DependencyObject)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定提供的 DependencyObject 是否等效于当前 DependencyObjectDetermines whether a provided DependencyObject is equivalent to the current DependencyObject.

(Inherited from DependencyObject)
FindCommonVisualAncestor(DependencyObject) FindCommonVisualAncestor(DependencyObject) FindCommonVisualAncestor(DependencyObject) FindCommonVisualAncestor(DependencyObject)

返回两个可视对象的公共上级。Returns the common ancestor of two visual objects.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

获取此 DependencyObject 的哈希代码。Gets a hash code for this DependencyObject.

(Inherited from DependencyObject)
GetLocalValueEnumerator() GetLocalValueEnumerator() GetLocalValueEnumerator() GetLocalValueEnumerator()

创建一个专用的枚举数,用于确定哪些依赖项属性在此 DependencyObject 上具有以本地方式设置的值。Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.

(Inherited from DependencyObject)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

DependencyObject 的此实例返回依赖属性的当前有效值。Returns the current effective value of a dependency property on this instance of a DependencyObject.

(Inherited from DependencyObject)
GetVisualChild(Int32) GetVisualChild(Int32) GetVisualChild(Int32) GetVisualChild(Int32)

返回父级 Visual 中的指定 VisualCollectionReturns the specified Visual in the parent VisualCollection.

HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters) HitTestCore(GeometryHitTestParameters)

确定可视对象的边界中是否存在几何图形值。Determines whether a geometry value is within the bounds of the visual object.

HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters) HitTestCore(PointHitTestParameters)

确定点坐标值是否在可视对象的边界内。Determines whether a point coordinate value is within the bounds of the visual object.

InvalidateProperty(DependencyProperty) InvalidateProperty(DependencyProperty) InvalidateProperty(DependencyProperty) InvalidateProperty(DependencyProperty)

重新计算指定依赖项属性的有效值Re-evaluates the effective value for the specified dependency property

(Inherited from DependencyObject)
IsAncestorOf(DependencyObject) IsAncestorOf(DependencyObject) IsAncestorOf(DependencyObject) IsAncestorOf(DependencyObject)

确定可视对象是否为后代可视对象的上级。Determines whether the visual object is an ancestor of the descendant visual object.

IsDescendantOf(DependencyObject) IsDescendantOf(DependencyObject) IsDescendantOf(DependencyObject) IsDescendantOf(DependencyObject)

确定可视对象是否为上级可视对象的后代。Determines whether the visual object is a descendant of the ancestor visual object.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
OnDpiChanged(DpiScale, DpiScale) OnDpiChanged(DpiScale, DpiScale) OnDpiChanged(DpiScale, DpiScale) OnDpiChanged(DpiScale, DpiScale)

呈现此视图时所使用的 DPI 发生变化时进行调用。Called when the DPI at which this View is rendered changes.

OnPropertyChanged(DependencyPropertyChangedEventArgs) OnPropertyChanged(DependencyPropertyChangedEventArgs) OnPropertyChanged(DependencyPropertyChangedEventArgs) OnPropertyChanged(DependencyPropertyChangedEventArgs)

每当更新此 DependencyObject 的任何依赖属性的有效值时调用。Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. 更改的特定依赖项属性将在事件数据中报告。The specific dependency property that changed is reported in the event data.

(Inherited from DependencyObject)
OnVisualChildrenChanged(DependencyObject, DependencyObject) OnVisualChildrenChanged(DependencyObject, DependencyObject) OnVisualChildrenChanged(DependencyObject, DependencyObject) OnVisualChildrenChanged(DependencyObject, DependencyObject)

修改可视对象的 VisualCollection 时调用。Called when the VisualCollection of the visual object is modified.

OnVisualParentChanged(DependencyObject) OnVisualParentChanged(DependencyObject) OnVisualParentChanged(DependencyObject) OnVisualParentChanged(DependencyObject)

当可视对象的父级更改时调用。Called when the parent of the visual object is changed.

PointFromScreen(Point) PointFromScreen(Point) PointFromScreen(Point) PointFromScreen(Point)

将屏幕坐标中的 Point 转换为表示 Point 的当前坐标系的 VisualConverts a Point in screen coordinates into a Point that represents the current coordinate system of the Visual.

PointToScreen(Point) PointToScreen(Point) PointToScreen(Point) PointToScreen(Point)

将表示 Point 的当前坐标系的 Visual 转换为屏幕坐标中的 PointConverts a Point that represents the current coordinate system of the Visual into a Point in screen coordinates.

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

如果存在,则返回依赖属性的本地值。Returns the local value of a dependency property, if it exists.

(Inherited from DependencyObject)
RemoveVisualChild(Visual) RemoveVisualChild(Visual) RemoveVisualChild(Visual) RemoveVisualChild(Visual)

移除两个可视对象之间的父子关系。Removes the parent-child relationship between two visuals.

SetCurrentValue(DependencyProperty, Object) SetCurrentValue(DependencyProperty, Object) SetCurrentValue(DependencyProperty, Object) SetCurrentValue(DependencyProperty, Object)

设置依赖属性的值而不更改其值源。Sets the value of a dependency property without changing its value source.

(Inherited from DependencyObject)
SetValue(DependencyProperty, Object) SetValue(DependencyProperty, Object) SetValue(DependencyProperty, Object) SetValue(DependencyProperty, Object)

设置依赖属性的本地值,该值由其依赖属性标识符指定。Sets the local value of a dependency property, specified by its dependency property identifier.

(Inherited from DependencyObject)
SetValue(DependencyPropertyKey, Object) SetValue(DependencyPropertyKey, Object) SetValue(DependencyPropertyKey, Object) SetValue(DependencyPropertyKey, Object)

设置一个只读依赖属性的本地值,该值由依赖属性的 DependencyPropertyKey 标识符指定。Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property.

(Inherited from DependencyObject)
ShouldSerializeProperty(DependencyProperty) ShouldSerializeProperty(DependencyProperty) ShouldSerializeProperty(DependencyProperty) ShouldSerializeProperty(DependencyProperty)

返回一个值,该值指示序列化进程是否应序列化所提供的依赖属性的值。Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.

(Inherited from DependencyObject)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
TransformToAncestor(Visual) TransformToAncestor(Visual) TransformToAncestor(Visual) TransformToAncestor(Visual)

返回一个转换,该转换可用于将 Visual 中的坐标转换为可视对象的指定 Visual 上级。Returns a transform that can be used to transform coordinates from the Visual to the specified Visual ancestor of the visual object.

TransformToAncestor(Visual3D) TransformToAncestor(Visual3D) TransformToAncestor(Visual3D) TransformToAncestor(Visual3D)

返回一个转换,该转换可用于将 Visual 中的坐标转换为可视对象的指定 Visual3D 上级。Returns a transform that can be used to transform coordinates from the Visual to the specified Visual3D ancestor of the visual object.

TransformToDescendant(Visual) TransformToDescendant(Visual) TransformToDescendant(Visual) TransformToDescendant(Visual)

返回一个转换,该转换可用于将 Visual 中的坐标转换为指定的可视对象后代。Returns a transform that can be used to transform coordinates from the Visual to the specified visual object descendant.

TransformToVisual(Visual) TransformToVisual(Visual) TransformToVisual(Visual) TransformToVisual(Visual)

返回一个转换,该转换可用于将 Visual 中的坐标转换为指定的可视对象。Returns a transform that can be used to transform coordinates from the Visual to the specified visual object.

VerifyAccess() VerifyAccess() VerifyAccess() VerifyAccess()

强制调用线程具有此 DispatcherObject 的访问权限。Enforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)

适用于

另请参阅