Container controls in WPF

If you are new wpf, want to know what are the available container controls in wpf and what are the properties for that controls to use then this article helps you to know the basic container controls in Windows Presentation Foundation(WPF).

Generally we will use container controls to positioning the child controls in a proper way. In every technology we have different controls available based on our requirement we may use that.In the same WPF has some controls for better positioning child controls. The available container controls are as follows


It is the most familiar control in wpf. When we add a new window in visual studio it will be with Grid control By default.Grid controls is used to provide a table layout functionality for our window. To divide the grid into rows and columns use the properties rowdefinitions and columndefinitions. Within the rowdefinitions property use the element rowdefinition to specify the number of rows in the grid and within the property columndefinitions use the columndefinition to specify number of columns in the grid.


Canvas control is used to place the child controls by specifying distance from left and top. For the child controls we have to set Canvas.Left and Canvas.Top properties.


StackPanel is used to arrange the child controls either in horizantal or vertical as in a stack. It has the property orientation to specify whether to arrange the controls vertical or horizantal. For the controls in stackpanel use the margin property to specify the space you want around the control


WrapPanel is used to arrange the controls row wise and column wise and wrap them to next row or next column when the row or column is filled. It has the Orientation to specify whether to arrange the controls horizantal and vertical.


DockPanel is used to arrange the controls by docking them to any of the four sides of the window. For the controls in dockpanel we have to set the dockpanel.dock property to specify to which side of the window we want to dock the control.

Reference:WPF Container controls Overview


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: