This documentation is archived and is not being maintained.

DynamicRenderer.OnDraw Method

Draws the ink in real-time so it appears to "flow" from the tablet pen or other pointing device.

Namespace:  System.Windows.Input.StylusPlugIns
Assembly:  PresentationCore (in PresentationCore.dll)

protected virtual void OnDraw(
	DrawingContext drawingContext,
	StylusPointCollection stylusPoints,
	Geometry geometry,
	Brush fillBrush


Type: System.Windows.Media.DrawingContext
The DrawingContext object onto which the stroke is rendered.
Type: System.Windows.Input.StylusPointCollection
The StylusPointCollection that represents the segment of the stroke to draw.
Type: System.Windows.Media.Geometry
A Geometry that represents the path of the mouse pointer.
Type: System.Windows.Media.Brush
A Brush that specifies the appearance of the current stroke.

Notes to Inheritors

When overriding OnDraw in a derived class, be sure to call the base class’s OnDraw method.

The following example demonstrates how to override the OnDraw method to dynamically render digital ink with a LinearGradientBrush.

protected override void OnDraw(DrawingContext drawingContext,
                               StylusPointCollection stylusPoints,
                               Geometry geometry, Brush fillBrush)
    // Create a new Brush, if necessary
    if (brush == null)
        Color primaryColor;

        if (fillBrush is SolidColorBrush)
            primaryColor = ((SolidColorBrush)fillBrush).Color;
            primaryColor = Colors.Red;

        brush = new LinearGradientBrush(Colors.Blue, primaryColor, 20d);

    drawingContext.DrawGeometry(brush, null, geometry);


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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