Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

UIElement.OnRender Method

When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
'Declaration
Protected Overridable Sub OnRender ( _
	drawingContext As DrawingContext _
)

Parameters

drawingContext
Type: System.Windows.Media.DrawingContext

The drawing instructions for a specific element. This context is provided to the layout system.

This method has no default implementation in the UIElement class.

Notes to Inheritors

The OnRender method can be overridden to add further graphical elements (not previously defined in a logical tree) to a rendered element, such as effects or adorners. A DrawingContext object is passed as an argument, which provides methods for drawing shapes, text, images or videos.

The following code example shows a possible implementation for a panel derived class.

			' Override the OnRender call to add a Background and Border to the OffSetPanel
			Protected Overrides Sub OnRender(ByVal dc As DrawingContext)
				Dim mySolidColorBrush As New SolidColorBrush()
				mySolidColorBrush.Color = Colors.LimeGreen
				Dim myPen As New Pen(Brushes.Blue, 10)
				Dim myRect As New Rect(0, 0, 500, 500)
				dc.DrawRectangle(mySolidColorBrush, myPen, myRect)
			End Sub

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.