Gtk.Container Class
Base class for widgets which contain other widgets

See Also: Container Members


public class Container : Widget, IEnumerable


A Gtk# user interface is constructed by nesting widgets inside widgets. Gtk.Container widgets are the inner nodes in the resulting tree of widgets: they contain other widgets. So, for example, you might have a Gtk.Window containing a Gtk.Frame containing a Gtk.Label. If you wanted an image instead of a textual label inside the frame, you might replace the Gtk.Label widget with a Gtk.Image widget.

There are two major kinds of Gtk.Container widgets in Gtk#. Both are subclasses of the abstract Gtk.Container base class.

The first type of Gtk.Container widget has a single child widget and derives from Gtk.Bin. These containers are decorators, which add some kind of functionality to the child. For example, a Gtk.Button makes its child into a clickable button; a Gtk.Frame draws a frame around its child and a Gtk.Window places its child widget inside a top-level Gtk.Window.

The second type of Gtk.Container can have more than one child; its purpose is to manage layout. This means that these containers assign sizes and positions to their children. For example, a Gtk.HBox arranges its children in a horizontal row, and a Gtk.Table arranges the widgets it contains in a two-dimensional grid.

To fulfill its task, a layout Gtk.Container must negotiate the size requirements with its parent and its children. This negotiation is carried out in two phases, size requisition and size allocation.


Namespace: Gtk
Assembly: gtk-sharp (in gtk-sharp.dll)
Assembly Versions: