Skip to main content
.NET Framework Class Library
Visual Class

Provides rendering support in WPF, which includes hit testing, coordinate transformation, and bounding box calculations.

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
Syntax
Public MustInherit Class Visual _
	Inherits [%$TOPIC/ms635637_en-us_VS_110_2_0_0_0_0%]
public abstract class Visual : [%$TOPIC/ms635637_en-us_VS_110_2_0_1_0_0%]
public ref class Visual abstract : public [%$TOPIC/ms635637_en-us_VS_110_2_0_2_0_0%]
[<[%$TOPIC/ms635637_en-us_VS_110_2_0_3_0_0%]>]
type Visual =  
    class 
        inherit [%$TOPIC/ms635637_en-us_VS_110_2_0_3_0_1%] 
    end

The Visual type exposes the following members.

Constructors
  NameDescription
Protected method VisualProvides the base initialization for objects derived from the Visual class.
Top
Properties
  NameDescription
Public property DependencyObjectTypeGets the DependencyObjectType that wraps the CLR type of this instance.  (Inherited from DependencyObject.)
Public property DispatcherGets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Public property IsSealedGets a value that indicates whether this instance is currently sealed (read-only). (Inherited from DependencyObject.)
Protected property VisualBitmapEffectObsolete. Gets or sets the BitmapEffect value for the Visual.
Protected property VisualBitmapEffectInputObsolete. Gets or sets the BitmapEffectInput value for the Visual.
Protected property VisualBitmapScalingModeGets or sets the BitmapScalingMode for the Visual.
Protected property VisualCacheModeGets or sets a cached representation of the Visual.
Protected property VisualChildrenCountGets the number of child elements for the Visual.
Protected property VisualClearTypeHintGets or sets the ClearTypeHint that determines how ClearType is rendered in the Visual.
Protected property VisualClipGets or sets the clip region of the Visual as a Geometry value.
Protected property VisualEdgeModeGets or sets the edge mode of the Visual as an EdgeMode value.
Protected property VisualEffectGets or sets the bitmap effect to apply to the Visual.
Protected property VisualOffsetGets or sets the offset value of the visual object.
Protected property VisualOpacityGets or sets the opacity of the Visual.
Protected property VisualOpacityMaskGets or sets the Brush value that represents the opacity mask of the Visual.
Protected property VisualParentGets the visual tree parent of the visual object.
Protected property VisualScrollableAreaClipGets or sets a clipped scrollable area for the Visual.
Protected property VisualTextHintingModeGets or sets the TextHintingMode of the Visual.
Protected property VisualTextRenderingModeGets or sets the TextRenderingMode of the Visual.
Protected property VisualTransformGets or sets the Transform value for the Visual.
Protected property VisualXSnappingGuidelinesGets or sets the x-coordinate (vertical) guideline collection.
Protected property VisualYSnappingGuidelinesGets or sets the y-coordinate (horizontal) guideline collection.
Top
Methods
  NameDescription
Protected method AddVisualChildDefines the parent-child relationship between two visuals.
Public method CheckAccessDetermines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Public method ClearValue(DependencyProperty)Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.)
Public method ClearValue(DependencyPropertyKey)Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.)
Public method CoerceValueCoerces the value of the specified dependency property. 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.)
Public method EqualsDetermines whether a provided DependencyObject is equivalent to the current DependencyObject. (Inherited from DependencyObject.)
Protected method FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method FindCommonVisualAncestorReturns the common ancestor of two visual objects.
Public method GetHashCodeGets a hash code for this DependencyObject. (Inherited from DependencyObject.)
Public method GetLocalValueEnumeratorCreates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method GetValueReturns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.)
Protected method GetVisualChildReturns the specified Visual in the parent VisualCollection.
Protected method HitTestCore(GeometryHitTestParameters)Determines whether a geometry value is within the bounds of the visual object.
Protected method HitTestCore(PointHitTestParameters)Determines whether a point coordinate value is within the bounds of the visual object.
Public method InvalidatePropertyRe-evaluates the effective value for the specified dependency property (Inherited from DependencyObject.)
Public method IsAncestorOfDetermines whether the visual object is an ancestor of the descendant visual object.
Public method IsDescendantOfDetermines whether the visual object is a descendant of the ancestor visual object.
Protected method MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnPropertyChangedInvoked 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.)
Protected method OnVisualChildrenChangedCalled when the VisualCollection of the visual object is modified.
Protected method OnVisualParentChangedCalled when the parent of the visual object is changed.
Public method PointFromScreenConverts a Point in screen coordinates into a Point that represents the current coordinate system of the Visual.
Public method PointToScreenConverts a Point that represents the current coordinate system of the Visual into a Point in screen coordinates.
Public method ReadLocalValueReturns the local value of a dependency property, if it exists. (Inherited from DependencyObject.)
Protected method RemoveVisualChildRemoves the parent-child relationship between two visuals.
Public method SetCurrentValueSets the value of a dependency property without changing its value source. (Inherited from DependencyObject.)
Public method SetValue(DependencyProperty, Object)Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.)
Public method SetValue(DependencyPropertyKey, Object)Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.)
Protected method ShouldSerializePropertyReturns a value that indicates whether serialization processes should serialize the value for the provided dependency property. (Inherited from DependencyObject.)
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Public method TransformToAncestor(Visual)Returns a transform that can be used to transform coordinates from the Visual to the specified Visual ancestor of the visual object.
Public method TransformToAncestor(Visual3D)Returns a transform that can be used to transform coordinates from the Visual to the specified Visual3D ancestor of the visual object.
Public method TransformToDescendantReturns a transform that can be used to transform coordinates from the Visual to the specified visual object descendant.
Public method TransformToVisualReturns a transform that can be used to transform coordinates from the Visual to the specified visual object.
Public method VerifyAccessEnforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Top
Remarks

The Visual class is the basic abstraction from which every FrameworkElement object derives. It also serves as the entry point for writing new controls in WPF, and in many ways can be thought of as an equivalent of a window handle (HWND) in the Win32 application model.

The Visual object is a core WPF object, whose primary role is to provide rendering support. User interface controls, such as Button and TextBox, derive from the Visual class, and use the Visual defined properties for persisting their rendering data. 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.

Architecturally, the Visual object does not include support for other application development requirements / WPF features that are not immediately related to its rendering, such as the following:

  • Event handling

  • Layout

  • Styles

  • Data binding

  • Globalization

Visual is provided as a public abstract class from which further classes can be derived. The following illustration shows the hierarchy of the existing visual objects that are defined in the WPF architecture.

Visual class hierarchy

Diagram of classes derived from the Visual object

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.

For more information, see WPF Graphics Rendering Overview.

A Visual has a limited number of levels. 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.

In .NET Framework 4, the maximum depth of a Visual is 2047, which enables much deeper visual trees. In most applications, there is not enough stack space to traverse so many levels, and the result is a StackOverflowException during layout. 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. 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. For more information, see Stack Allocations and EDITBIN Options.

Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.