UIElement.OnRender Method
.NET Framework 3.0
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)
Assembly: PresentationCore (in presentationcore.dll)
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 override void OnRender(DrawingContext dc) { SolidColorBrush mySolidColorBrush = new SolidColorBrush(); mySolidColorBrush.Color = Colors.LimeGreen; Pen myPen = new Pen(Brushes.Blue, 10); Rect myRect = new Rect(0, 0, 500, 500); dc.DrawRectangle(mySolidColorBrush, myPen, myRect); }
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: