Visual 類別

定義

提供在 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中撰寫新控制項的進入點,而在許多方面,您可以將其視為 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.

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 中定義為 protected 的成員,會在衍生的 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. 在大部分的應用程式中,沒有足夠的堆疊空間可以跨越太多層級,而且結果會在配置期間 StackOverflowExceptionIn 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. 如需詳細資訊,請參閱堆疊配置和EDITBIN 選項For more information, see Stack Allocations and EDITBIN Options.

建構函式

Visual()

提供衍生自 Visual 類別之物件的基底初始化。Provides the base initialization for objects derived from the Visual class.

屬性

DependencyObjectType

取得包裝此執行個體之 DependencyObjectType 型別的 CLRCLRGets the DependencyObjectType that wraps the CLRCLR type of this instance.

(繼承來源 DependencyObject)
Dispatcher

取得與這個 Dispatcher 關聯的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

(繼承來源 DispatcherObject)
IsSealed

取得值,這個值表示此執行個體目前是否已密封 (唯讀)。Gets a value that indicates whether this instance is currently sealed (read-only).

(繼承來源 DependencyObject)
VisualBitmapEffect

取得或設定 BitmapEffectVisual 值。Gets or sets the BitmapEffect value for the Visual.

VisualBitmapEffectInput

取得或設定 BitmapEffectInputVisual 值。Gets or sets the BitmapEffectInput value for the Visual.

VisualBitmapScalingMode

取得或設定 BitmapScalingModeVisualGets or sets the BitmapScalingMode for the Visual.

VisualCacheMode

取得或設定 Visual 的快取表示。Gets or sets a cached representation of the Visual.

VisualChildrenCount

取得 Visual 的子項目數量。Gets the number of child elements for the Visual.

VisualClearTypeHint

取得或設定 ClearTypeHint,以決定 Visual 中的 ClearType 呈現方式。Gets or sets the ClearTypeHint that determines how ClearType is rendered in the Visual.

VisualClip

取得或設定 Visual 的裁剪區域做為 Geometry 值。Gets or sets the clip region of the Visual as a Geometry value.

VisualEdgeMode

取得或設定 Visual 的邊緣模式做為 EdgeMode 值。Gets or sets the edge mode of the Visual as an EdgeMode value.

VisualEffect

取得或設定要套用至 Visual 的點陣圖效果。Gets or sets the bitmap effect to apply to the Visual.

VisualOffset

取得或設定視覺物件的位移值。Gets or sets the offset value of the visual object.

VisualOpacity

取得或設定 Visual 的不透明度。Gets or sets the opacity of the Visual.

VisualOpacityMask

取得或設定 Brush 值,這個值表示 Visual 的不透明遮罩。Gets or sets the Brush value that represents the opacity mask of the Visual.

VisualParent

取得視覺物件的視覺化樹狀結構父物件。Gets the visual tree parent of the visual object.

VisualScrollableAreaClip

取得或設定 Visual 的可捲動裁剪區域。Gets or sets a clipped scrollable area for the Visual.

VisualTextHintingMode

取得或設定 TextHintingModeVisualGets or sets the TextHintingMode of the Visual.

VisualTextRenderingMode

取得或設定 TextRenderingModeVisualGets or sets the TextRenderingMode of the Visual.

VisualTransform

取得或設定 TransformVisual 值。Gets or sets the Transform value for the Visual.

VisualXSnappingGuidelines

取得或設定 X 座標 (垂直) 導線集合。Gets or sets the x-coordinate (vertical) guideline collection.

VisualYSnappingGuidelines

取得或設定 Y 座標 (水平) 導線集合。Gets or sets the y-coordinate (horizontal) guideline collection.

方法

AddVisualChild(Visual)

定義兩個視覺項目之間的父-子關係。Defines the parent-child relationship between two visuals.

CheckAccess()

判斷呼叫的執行是否可以存取這個 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

(繼承來源 DispatcherObject)
ClearValue(DependencyProperty)

清除屬性的區域數值。Clears the local value of a property. 要清除的屬性是由 DependencyProperty 識別項所指定。The property to be cleared is specified by a DependencyProperty identifier.

(繼承來源 DependencyObject)
ClearValue(DependencyPropertyKey)

清除唯讀屬性的區域數值。Clears the local value of a read-only property. 要清除的屬性是由 DependencyPropertyKey 所指定。The property to be cleared is specified by a DependencyPropertyKey.

(繼承來源 DependencyObject)
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.

(繼承來源 DependencyObject)
Equals(Object)

判斷提供的 DependencyObject 和目前的 DependencyObject 是否相等。Determines whether a provided DependencyObject is equivalent to the current DependencyObject.

(繼承來源 DependencyObject)
FindCommonVisualAncestor(DependencyObject)

傳回兩個視覺物件的共同祖系。Returns the common ancestor of two visual objects.

GetHashCode()

取得這個 DependencyObject 的雜湊碼。Gets a hash code for this DependencyObject.

(繼承來源 DependencyObject)
GetLocalValueEnumerator()

建立特定的列舉值,以判斷哪些相依性屬性在此 DependencyObject 上具有本機設定的值。Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.

(繼承來源 DependencyObject)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GetValue(DependencyProperty)

傳回 DependencyObject 的這個執行個體上之相依性屬性的目前有效值。Returns the current effective value of a dependency property on this instance of a DependencyObject.

(繼承來源 DependencyObject)
GetVisualChild(Int32)

傳回父 Visual 中所指定的 VisualCollectionReturns the specified Visual in the parent VisualCollection.

HitTestCore(GeometryHitTestParameters)

判斷幾何值是否在視覺物件的界限中。Determines whether a geometry value is within the bounds of the visual object.

HitTestCore(PointHitTestParameters)

判斷點座標值是否在視覺物件的界限中。Determines whether a point coordinate value is within the bounds of the visual object.

InvalidateProperty(DependencyProperty)

重新評估指定相依性屬性的有效值。Re-evaluates the effective value for the specified dependency property.

(繼承來源 DependencyObject)
IsAncestorOf(DependencyObject)

判斷視覺物件是否為子系視覺物件的祖系。Determines whether the visual object is an ancestor of the descendant visual object.

IsDescendantOf(DependencyObject)

判斷視覺物件是否為祖系視覺物件的子系。Determines whether the visual object is a descendant of the ancestor visual object.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnDpiChanged(DpiScale, DpiScale)

當轉譯此 View 的 DPI 變更時呼叫。Called when the DPI at which this View is rendered changes.

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.

(繼承來源 DependencyObject)
OnVisualChildrenChanged(DependencyObject, DependencyObject)

當視覺物件的 VisualCollection 已修改時呼叫。Called when the VisualCollection of the visual object is modified.

OnVisualParentChanged(DependencyObject)

在視覺物件的父代變更時呼叫。Called when the parent of the visual object is changed.

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)

將表示 Point 之目前座標系統的 Visual 轉換為螢幕座標中的 PointConverts a Point that represents the current coordinate system of the Visual into a Point in screen coordinates.

ReadLocalValue(DependencyProperty)

傳回相依性屬性的區域值 (如果存在)。Returns the local value of a dependency property, if it exists.

(繼承來源 DependencyObject)
RemoveVisualChild(Visual)

移除兩個視覺物件之間的父-子關係。Removes the parent-child relationship between two visuals.

SetCurrentValue(DependencyProperty, Object)

設定相依性屬性的值,而不需要變更其值來源。Sets the value of a dependency property without changing its value source.

(繼承來源 DependencyObject)
SetValue(DependencyProperty, Object)

設定相依性屬性的區域值 (由相依性屬性的識別碼所指定)。Sets the local value of a dependency property, specified by its dependency property identifier.

(繼承來源 DependencyObject)
SetValue(DependencyPropertyKey, Object)

設定唯讀相依性屬性的區域數值 (由相依性屬性的 DependencyPropertyKey 識別項所指定)。Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property.

(繼承來源 DependencyObject)
ShouldSerializeProperty(DependencyProperty)

傳回值,這個值表示序列化程序是否應該序列化所提供相依性屬性的值。Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.

(繼承來源 DependencyObject)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
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)

傳回轉換,這個轉換可用來將 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)

傳回轉換,這個轉換可用來將 Visual 的座標轉換為指定的視覺物件子系。Returns a transform that can be used to transform coordinates from the Visual to the specified visual object descendant.

TransformToVisual(Visual)

傳回轉換,這個轉換可用來將 Visual 的座標轉換為指定的視覺物件。Returns a transform that can be used to transform coordinates from the Visual to the specified visual object.

VerifyAccess()

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

(繼承來源 DispatcherObject)

適用於

另請參閱