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
Only primitive controls that directly have to draw on the device context, like
BorderorTextBlockoverrideOnRenderto 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
MeasureOverrideandArrangeOverride.That being said, if you don’t want to render anything, it’s better to set the
Visibilityof the control toCollapsed.