DrawingContext.DrawRectangle Method

Definition

Draws a rectangle.

Overloads

DrawRectangle(Brush, Pen, Rect)

Draws a rectangle with the specified Brush and Pen. The pen and the brush can be null.

DrawRectangle(Brush, Pen, Rect, AnimationClock)

Draws a rectangle with the specified Brush and Pen and applies the specified animation clocks.

DrawRectangle(Brush, Pen, Rect)

Draws a rectangle with the specified Brush and Pen. The pen and the brush can be null.

C#
public abstract void DrawRectangle(System.Windows.Media.Brush brush, System.Windows.Media.Pen pen, System.Windows.Rect rectangle);

Parameters

brush
Brush

The brush with which to fill the rectangle. This is optional, and can be null. If the brush is null, no fill is drawn.

pen
Pen

The pen with which to stroke the rectangle. This is optional, and can be null. If the pen is null, no stroke is drawn.

rectangle
Rect

The rectangle to draw.

Remarks

The brush and the pen can both be null. If the brush is null, then no fill is performed. If the pen is null, then no stroke is performed. If both the pen and the brush are null, then the drawing is not visible.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

DrawRectangle(Brush, Pen, Rect, AnimationClock)

Draws a rectangle with the specified Brush and Pen and applies the specified animation clocks.

C#
public abstract void DrawRectangle(System.Windows.Media.Brush brush, System.Windows.Media.Pen pen, System.Windows.Rect rectangle, System.Windows.Media.Animation.AnimationClock rectangleAnimations);

Parameters

brush
Brush

The brush with which to fill the rectangle. This is optional, and can be null. If the brush is null, no fill is drawn.

pen
Pen

The pen with which to stroke the rectangle. This is optional, and can be null. If the pen is null, no stroke is drawn.

rectangle
Rect

The rectangle to draw.

rectangleAnimations
AnimationClock

The clock with which to animate the rectangle's size and dimensions, or null for no animation. This clock must be created from an AnimationTimeline that can animate Rect objects.

Remarks

The brush and the pen can both be null. If the brush is null, then no fill is performed. If the pen is null, then no stoke is performed. If both the pen and the brush are null, then the drawing is not visible.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10