views:

89

answers:

1

In WPF, it is very easy to make resizable graphics/artwork. You simply create a DrawingBrush and use it as the fill for a Rectangle or a Shape. Or, you can simply use a VisualBrush that refers to Canvas with Shapes/Paths on it.

In Silverlight, though, there isn't a DrawingBrush and there isn't a VisualBrush. So, how does one best create graphics in Silverlight that are resizable?

I've played around with using Path and setting the Stretch property to Uniform ... and even taking a couple paths and combining them into a compound path ... but there are limits to this approach (e.g. the fill doesn't always fill where you want it to if the paths overlap).

I've also simply put a Viewbox around a Canvas that has Shapes/Paths on it.

How do you do it? And, what do you think the best practice is?

A: 

Hmm. The more I play with this, the more I like simply putting a Viewbox around something.

I guess that does come at the cost of another reference (i.e. to the Silverlight Toolkit) ... since the Silverlight Viewbox currently lives in the toolkit ... but you are already probably referencing that anyways ... and eventually Viewbox will get rolled into the Silverlight SDK proper.

I still miss DrawingBrush and VisualBrush, though, and wish Silverlight had them.

cplotts
Problem is someone else will miss some other feature and yet another person will miss something else entirely. We might wish that SL was completely compatible with WPF but then we'd still want it all to fit in a 5MB download, be entirely sandboxed so it can't be mis-used and oh yes run across multple platforms.
AnthonyWJones
Ha! True, very true.
cplotts