I have a simple solution: Instead of inheritance, you can create a class that alters a Brush properties throw attached properties. For example:
I created a class named "HatchBrushes" that can create 55 DrawingBrushes with deferent hatch styles (similar to WinForms HatchBrush.. In fact this part of code belongs to another programer)
The HatchBrushes class defines 4 attached properties that controls the hatch brush appearance: HatchStyle, Background, Foreground, and PenThickness. All these properties register a PropertyChangedCallBck sub named "OnHatchChanged", where I can change the properties of the DrawingBrush:
Shared Sub OnHatchChanged(d As DependencyObject, e As DependencyPropertyChangedEventArgs)
Dim DBrush = TryCast(d, DrawingBrush)
If DBrush Is Nothing Then Return
Dim B = GetHatchBrush(GetHatchStyle(DBrush), GetBackground(DBrush), GetForeground(DBrush), GetPenThickness(DBrush))
DBrush.Drawing = B.Drawing.CloneCurrentValue
DBrush.Stretch = B.Stretch
DBrush.ViewportUnits = B.ViewportUnits
DBrush.Viewport = B.Viewport
DBrush.TileMode = B.TileMode
End Sub
Note that "GetHatchBrush" is a function that creates a DrawingBrush with the desired HatchStyle. I wont write it here because it is too long.
Now, I can color the background of the window with a Horizontal-lines Hatch with simole xaml code like this:
<DrawingBrush c:HatchBrushes.HatchStyle="Horizontal"
c:HatchBrushes.Background="Red"
c:HatchBrushes.Foreground="Yellow"
c:HatchBrushes.PenThickness="2"/>