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


Visual類別是基本抽象,從中每FrameworkElement物件衍生。The Visual class is the basic abstraction from which every FrameworkElement object derives. 它也可以做為撰寫新控制項的進入點WPFWPF,並在許多方面可以視為對等的視窗控制代碼 (HWND) 中Win32Win32應用程式模型。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.

Visual物件是核心WPFWPF物件,其主要角色是提供轉譯支援。The Visual object is a core WPFWPF object, whose primary role is to provide rendering support. 使用者介面控制項,例如ButtonTextBox,衍生自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.

圖表的類別衍生自 Visual 物件Diagram of classes derived from the Visual object
Visual 類別階層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.

AVisual具有有限的數目的層級。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,其對應至即將巢狀的 190TreeViewItem物件。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. 如需詳細資訊,請參閱 < 堆疊配置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

取得DispatcherDispatcherObject相關聯。Gets 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. 叫用存在於呼叫 CoerceValueCallback 上相依性屬性之屬性中繼資料內所指定的任何 DependencyObject 函式,就可以達到這一點。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 和目前的 DependencyObject 是否相等。Determines 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)

當轉譯此 View 的 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,表示 Visual 的目前座標系統。Converts 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()

強制執行呼叫的執行緒可以存取這個DispatcherObjectEnforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)