In This Article

CanvasDrawContext Class

Provides access for drawing the content of a CanvasControl.

public class CanvasDrawContext
Inheritance:
object object

Constructors

CanvasDrawContext(CanvasControl, DrawingContext, Rect)

Initializes an instance of the class.

public CanvasDrawContext(CanvasControl canvas, DrawingContext drawingContext, Rect bounds)
Parameter Type Description
canvas CanvasControl

The canvas being drawn.

drawingContext DrawingContext

The native object used for drawing.

bounds Rect

The bounds in which to draw.

Properties

Bounds

The bounds in which to draw.

public Rect Bounds { get; }

Property Value

Rect

Canvas

The canvas being drawn.

public CanvasControl Canvas { get; }

Property Value

CanvasControl

PlatformRenderer

The native object used for drawing.

public DrawingContext PlatformRenderer { get; }

Property Value

DrawingContext

Methods

DrawLine(Point, Point, Pen)

Draws a line.

public void DrawLine(Point startLocation, Point endLocation, Pen pen)
Parameter Type Description
startLocation Point

The start location of the line.

endLocation Point

The end location of the line.

pen Pen

The line pen.

DrawRectangle(Rect, Pen)

Draws a rectangle shape.

public void DrawRectangle(Rect bounds, Pen pen)
Parameter Type Description
bounds Rect

The bounds in which to draw.

pen Pen

The line pen.

DrawText(FormattedText, Point)

Draws text.

public void DrawText(FormattedText formattedText, Point origin)
Parameter Type Description
formattedText FormattedText

The formatted text, prepared by the caller for the target DPI.

origin Point

The origin point.

DrawText(TextLayout, Point)

Draws a text layout.

public void DrawText(TextLayout textLayout, Point origin)
Parameter Type Description
textLayout TextLayout

The text layout.

origin Point

The origin point.

FillRectangle(Rect, IBrush)

Fills a rectangle shape.

public void FillRectangle(Rect bounds, IBrush brush)
Parameter Type Description
bounds Rect

The bounds in which to draw.

brush IBrush

The fill brush.

PushClip(Rect)

Pushes a clip.

public DrawingContext.PushedState PushClip(Rect clipBounds)
Parameter Type Description
clipBounds Rect

The clip bounds. Native clipping intersects this with any outer clip.

Returns

DrawingContext.PushedState:

A scope that restores the prior drawing state when disposed in reverse push order.

PushOpacity(double)

Pushes an opacity value.

public DrawingContext.PushedState PushOpacity(double opacity)
Parameter Type Description
opacity double

The opacity.

Returns

DrawingContext.PushedState:

A scope that restores the prior drawing state when disposed in reverse push order.

Inherited Members

Extension Methods