There is a description of what exactly distinguishes UserControl from ContentControl in Pro WPF, which provides more information than MSDN. Here is a direct link to the section:
http://books.google.ca/books?id=znAVMHNSen0C&pg=PA518&lpg=PA518&dq=%22taking ++ = 0CC8Q6AEwAQ # v = onepage & q =% 22taking% 20a% 20closer% 20look% 20at% 20user% 20controls% 22 & f = false
The most interesting difference is how it handles routed events. All events caused by the contained elements have a Source reset for the UserControl itself.
I think the conceptual difference is that ContentControl "contains" its content, while UserControl content is a "part" of UserControl. Thus, ContentControl is a separate element (custom / tab tab), the contents of which are processed separately; and customizing the contents of UserControl is part of its design process, the elements of which are processed directly in the code of the UserControl code.
So my rules are:
- If the user should inherit it, and handle content in the code, inherit
UserControl . - If it is intended to use as-is and arbitrary content is specified, inherit the
ContentControl . - If it defines its own content and does not have a placeholder for arbitrary content, inherit
Control and set its Template .
If you just want a surface rendering, I donβt think you will need Control . You can use an ImageSource for this, such as InteropBitmap or D3DImage , which you can bind to ImageBrush . For example, it can be used in a separate rectangle:
<Rectangle> <Rectangle.Fill> <ImageBrush> <ImageBrush.ImageSource> </ImageBrush.ImageSource> </ImageBrush> </Rectangle.Fill> <Rectangle>
Or in another place that Brush accepts, including Background another control.
source share