DynamicRenderer.OnDraw Method (DrawingContext, StylusPointCollection, Geometry, Brush)


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
Available since 3.0
Return to top