Why ContentElement is not part of the Visual tree
I w开发者_如何学Goas wondering if anybody knew why ContentElement doesn't derive from visual, and as a result is not part of the visual tree (the logic behind it). It seems more work to have to add it to a host element which then uses methods to add it to nodes of the logical tree so it can participate in the event routing. It kind of follows the same approach with drawing which doesn't derive from visual and has to be hosted in a visual element.
ContentElement is used for textual content. Text has layout requirements that differ from standard controls (deriving from Visual). For this reason ContentElement derives directly from DependencyObject and not Visual.
ContentElement does not have rendering content but needs to be hosted in a class deriving from Visual in order to be rendered on screen.
(edit: ContentControl and ContentElement are very different beasts)
精彩评论