Question

I have a set of simple geometries in WPF (check mark, arrows, etc.) I have these defined by Path which is nice because they are actually rendered rather than being rasterized.

The trouble I have is that I want to be able to change some of the properties of the Path (the Fill in particular) and I'm struggle as to how to implement. Do I use Styles, do I have something that contains it like UserControl? I'll have a handful of these so I don't want to have a bunch of duplicate controls.

I can't actually have a type that derives from Path because the class is sealed. That was where I went first.

Was it helpful?

Solution

So what finally worked was I created a control that derived from ViewBox. On the ViewBox I added a "FillBrush" dependency property of type Brush.

I then just stamp out instances of this control and fill it with Path objects that have the correct Data and bind their Fill property to the FillBrush dependency property.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top