开发者

Rendering order in ContentControl - WPF

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) st开发者_JAVA技巧ill 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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜