WPF: What is the generic container control? WPF: What is the generic container control? wpf wpf

WPF: What is the generic container control?


I think the closest thing to what you're looking for is a ContentControl. It does no layout of its own and has no default UI (unless you template it to do one or both of those) but can take any object as it's Content property (WPF UIElement or otherwise) and provide any UI for a CLR object through a DataTemplate assigned to its ContentTemplate property. In that respect it provides a good place to inject other content (like a div in HTML). It also happens to be a base class for many of the standard built-in controls: Button, ListBoxItem, UserControl, Window.

WPF panels don't work as well for placeholders because they can't be templated or have children set through bindings, excepting cases where they are contained in other controls that handle injecting bound content, like the ItemsControl-ItemsPresenter-ItemsPanel relationship.


Some of the more commonly used containers are:

Grid
StackPanel
DockPanel
WrapPanel
Canvas

See also MSDN Panels Overview.