Header Ads

WPF Container Controls

1.Grid

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.

2.Canvas

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.

3.StackPanel

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

4.DockPanel

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.

No comments:

Powered by Blogger.