I'd like to spruce up the WPF TreeView and add some functionality to it that needs to draw lines between the items of the TreeView. For that I created my own control inheriting from TreeView and drawing the lines in the OnRender override of that control:
Public Class MyTreeView
Inherits TreeView
Protected Overrides Sub OnRender(drawingContext As DrawingContext)
MyBase.OnRender(drawingContext)
drawingContext.DrawLine(New Pen(Brushes.Black, 1), New Point(0, 0), New Point(Me.ActualWidth, Me.ActualHeight))
End Sub
End Class
But I can only see my drawings in the running program, when I set the Background of my TreeView to Transparent.
<local:MyTreeView Background="Transparent" />
As soon as I put a white or gradient background to my TreeView it hides my drawings.
Is it possible to add some drawings in the OnRender override, that is rendered on top of the given Background?
For reasons that belong to another question I can't work with a transparent background and I can't work with a Border with background under a transparent TreeView simulating the background in the TreeView.