How to: Override the Panel OnRender Method
Use the OnRender method in order to add graphical effects to a rendered panel element. For example, you can use this method to add custom border or background effects. A DrawingContext object is passed as an argument, which provides methods for drawing shapes, text, images, or videos. As a result, this method is useful for customization of a panel object.
' 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