views:

112

answers:

1

Hi,

There is something that I don't understand regarding ContentControl: I've a class that inherits from ContentControl, and it overrides the OnRender method. And although I don't call base.OnRender(drawingContext) still the content is being rendered...

How come?

What am I missing?

Thanks, Eden

+1  A: 

Only primitive controls that directly have to draw on the device context, like Border or TextBlock override OnRender to do their jobs. Since most of controls are just a combination of those primitives, they don't draw directly. Instead, they're measuring and arranging their children so that they are at the good position and size.

What you need to override are the methods MeasureOverride and ArrangeOverride.

That being said, if you don't want to render anything, it's better to set the Visibility of the control to Collapsed.

Julien Lebosquain