Stroke.Draw Method (DrawingContext, DrawingAttributes)


Renders the Stroke object based upon the specified DrawingContext and DrawingAttributes.

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

public void Draw(
	DrawingContext drawingContext,
	DrawingAttributes drawingAttributes


Type: System.Windows.Media.DrawingContext

The DrawingContext object onto which the stroke will be rendered.

Type: System.Windows.Ink.DrawingAttributes

The DrawingAttributes object defining the attributes of the stroke that is drawn.

The following example demonstrates how to draw a Stroke object by using a DrawingContext and DrawingAttributes.

protected DrawingVisual DrawDCandDA(Stroke myStroke)
    // Create new Visual context to draw on
    DrawingVisual myVisual = new DrawingVisual();
    DrawingContext myContext = myVisual.RenderOpen();

    // Draw stroke using DrawingContext and DrawingAttributes
    // (to make the stroke magenta)
    DrawingAttributes myDAs = new DrawingAttributes();
    myDAs.Color = Colors.Magenta;

    myStroke.Draw(myContext, myDAs);

    // Close the context

    return myVisual;

.NET Framework
Available since 3.0
Return to top