This documentation is archived and is not being maintained.

StrokeCollection.Draw Method

Draws the strokes in the StrokeCollection.

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

public void Draw(
	DrawingContext context
)
You cannot use methods in XAML.

Parameters

context
Type: System.Windows.Media.DrawingContext

The DrawingContext on which to draw the StrokeCollection.

The following example creates a custom element that displays a thumbnail view of an InkCanvas. The custom element keeps a reference to an InkCanvas and redraws itself when the StrokeCollected event occurs.

public class InkThumbnail : FrameworkElement
{
    private InkCanvas sourceInkCanvas = null;

    // Get the InkCanvas that the user draws on. 
    public InkCanvas Source
    {

        get 
        { 
            return sourceInkCanvas; 
        }

        set
        {

            if (sourceInkCanvas != null)
            {
                // Detach the event handler from the former InkCanvas.
                sourceInkCanvas.StrokeCollected -= new InkCanvasStrokeCollectedEventHandler(SourceChanged);
            }

            sourceInkCanvas = value;


            if (sourceInkCanvas != null)
            {
                // Attach the even handler to the InkCannvas
                sourceInkCanvas.StrokeCollected += new InkCanvasStrokeCollectedEventHandler(SourceChanged);
            }

        }
    }

    // Handle the StrokeCollection event of the InkCanvas. 
    private void SourceChanged(object sender, InkCanvasStrokeCollectedEventArgs e)
    {

        // Cause the thumbnail to be redrawn. 
        this.InvalidateVisual();
    }


    protected override void OnRender(DrawingContext drawingContext)
    {

        base.OnRender(drawingContext);

        // Draw the strokes from the InkCanvas at 1/4 of their size.
        drawingContext.PushTransform(new ScaleTransform(0.25, 0.25));

        if (sourceInkCanvas != null)
        {
            sourceInkCanvas.Strokes.Draw(drawingContext);
        }
    }


}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0
Show: