Aracılığıyla paylaş


Nasıl yapılır: Panel OnRender Yöntemini Geçersiz Kılma

Bu örnekte, bir düzen öğesine özel grafik efektleri eklemek için OnRenderPanel yönteminin nasıl geçersiz kılınması gösterilmektedir.

Örnek

İşlenen panel öğesine grafik efektleri eklemek için OnRender yöntemini kullanın. Örneğin, özel kenarlık veya arka plan efektleri eklemek için bu yöntemi kullanabilirsiniz. "Bir DrawingContext nesnesi, şekil, metin, resim veya video çizme yöntemleri sağlayan bir argüman olarak geçirilir." Sonuç olarak, bu yöntem bir panel nesnesini özelleştirmek için kullanışlıdır.

// 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);
}
' 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

Ayrıca bakınız