DrawingContext Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Describes visual content using draw, push, and pop commands.

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

System::Object
  System.Windows.Threading::DispatcherObject
    System.Windows.Media::DrawingContext

public ref class DrawingContext abstract : DispatcherObject, 
	IDisposable

NameDescription
System_CAPS_pubpropertyDispatcher

Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)

NameDescription
System_CAPS_pubmethodCheckAccess()

Determines whether the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

System_CAPS_pubmethodClose()

Closes the DrawingContext and flushes the content. Afterward, the DrawingContext cannot be modified.

System_CAPS_protmethodDisposeCore()

Releases all resources used by the DrawingContext.

System_CAPS_pubmethodDrawDrawing(Drawing^)

Draws the specified Drawing object.

System_CAPS_pubmethodDrawEllipse(Brush^, Pen^, Point, AnimationClock^, Double, AnimationClock^, Double, AnimationClock^)

Draws an ellipse with the specified Brush and Pen and applies the specified animation clocks.

System_CAPS_pubmethodDrawEllipse(Brush^, Pen^, Point, Double, Double)

Draws an ellipse with the specified Brush and Pen.

System_CAPS_pubmethodDrawGeometry(Brush^, Pen^, Geometry^)

Draws the specified Geometry using the specified Brush and Pen.

System_CAPS_pubmethodDrawGlyphRun(Brush^, GlyphRun^)

Draws the specified text.

System_CAPS_pubmethodDrawImage(ImageSource^, Rect)

Draws an image into the region defined by the specified Rect.

System_CAPS_pubmethodDrawImage(ImageSource^, Rect, AnimationClock^)

Draws an image into the region defined by the specified Rect and applies the specified animation clock.

System_CAPS_pubmethodDrawLine(Pen^, Point, AnimationClock^, Point, AnimationClock^)

Draws a line between the specified points using the specified Pen and applies the specified animation clocks.

System_CAPS_pubmethodDrawLine(Pen^, Point, Point)

Draws a line between the specified points using the specified Pen.

System_CAPS_pubmethodDrawRectangle(Brush^, Pen^, Rect)

Draws a rectangle with the specified Brush and Pen. The pen and the brush can be null.

System_CAPS_pubmethodDrawRectangle(Brush^, Pen^, Rect, AnimationClock^)

Draws a rectangle with the specified Brush and Pen and applies the specified animation clocks.

System_CAPS_pubmethodDrawRoundedRectangle(Brush^, Pen^, Rect, AnimationClock^, Double, AnimationClock^, Double, AnimationClock^)

Draws a rounded rectangle with the specified Brush and Pen and applies the specified animation clocks.

System_CAPS_pubmethodDrawRoundedRectangle(Brush^, Pen^, Rect, Double, Double)

Draws a rounded rectangle with the specified Brush and Pen.

System_CAPS_pubmethodDrawText(FormattedText^, Point)

Draws formatted text at the specified location.

System_CAPS_pubmethodDrawVideo(MediaPlayer^, Rect)

Draws a video into the specified region.

System_CAPS_pubmethodDrawVideo(MediaPlayer^, Rect, AnimationClock^)

Draws a video into the specified region and applies the specified animation clock.

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodPop()

Pops the last opacity mask, opacity, clip, effect, or transform operation that was pushed onto the drawing context.

System_CAPS_pubmethodPushClip(Geometry^)

Pushes the specified clip region onto the drawing context.

System_CAPS_pubmethodPushEffect(BitmapEffect^, BitmapEffectInput^)

Obsolete. Pushes the specified BitmapEffect onto the drawing context.

System_CAPS_pubmethodPushGuidelineSet(GuidelineSet^)

Pushes the specified GuidelineSet onto the drawing context.

System_CAPS_pubmethodPushOpacity(Double)

Pushes the specified opacity setting onto the drawing context.

System_CAPS_pubmethodPushOpacity(Double, AnimationClock^)

Pushes the specified opacity setting onto the drawing context and applies the specified animation clock.

System_CAPS_pubmethodPushOpacityMask(Brush^)

Pushes the specified opacity mask onto the drawing context.

System_CAPS_pubmethodPushTransform(Transform^)

Pushes the specified Transform onto the drawing context.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodVerifyAccess()

Enforces that the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

System_CAPS_protmethodVerifyApiNonstructuralChange()

This member supports the WPF infrastructure and is not intended to be used directly from your code. 

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDisposable::Dispose()

This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

Use a DrawingContext to populate a Visual or a Drawing with visual content.

Although the DrawingContext draw methods appear similar to the draw methods of the System.Drawing::Graphics type, they function very differently: DrawingContext is used with a retained mode graphics system, while the System.Drawing::Graphics type is used with an immediate mode graphics system. When you use a DrawingContext object's draw commands, you are actually storing a set of rendering instructions (although the exact storage mechanism depends on the type of object that supplies the DrawingContext) that will later be used by the graphics system; you are not drawing to the screen in real-time. For more information about how the Windows Presentation Foundation (WPF) graphics system works, see WPF Graphics Rendering Overview.

You never directly instantiate a DrawingContext; you can, however, acquire a drawing context from certain methods, such as DrawingGroup::Open and DrawingVisual::RenderOpen.

The following example retrieves a DrawingContext from a DrawingVisual and uses it to draw a rectangle.

No code example is currently available or this language may not be supported.

The next example demonstrates the PushOpacity, PushEffect, and Pop commands. The DrawingContext is obtained from a DrawingGroup and displayed using an Image control.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.0

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

Return to top
Show: