tags:

views:

390

answers:

2

I can't find any documentation on implementing a class that inherits System.Windows.Media.Brush - what would it need to provide to do the job?

My specific goal is a triangle gradient; I can handle the details of calculating the colors if I can just find out how to actually implement a new brush.

A: 

Doesn't seem to be any guides to extending System.Windows.Media.Brush. But it looks like they provide a brush that will render a drawing that you give it. DrawingBrush

Samuel
A: 

It seems like Brush and other drawing primitives are explicitly sealed or prevented from subclassing by adding internal abstract methods for performance reasons.

See this post from Microsoft.

It is a bit misleading given this line in MSDN:

Notes to Inheritors:

When you inherit from the Brush class, you must override the CreateInstanceCore method. Depending on whether your class must perform additional initialization work or contains non-dependency property data members, you might need to override additional Freezable methods. For more information about inheriting from Freezable types, see the Freezable Objects Overview.

It seems to imply that if they are giving notes to inheritors that it should be possible to inherit from Brush, but Brush has some internal abstract methods that can't be overridden by a third-party class.

Eclipse