What are layouts available in WPF?
This article will be useful for people who are good at programming but not in designing GUI. I have included various layout information which can be used at the time of developing page. I hope you will like this article.
While using application, choosing layout is challenging thing because it may or may not fascinate users for using your application.
Arranging controls based on fixed pixel co-ordinates may work for a limited environment; it may fail for different resolution and for different font sizes.
There are so many built-in layout panels available in WPF for relative and absolute control arrangement.
Following are most used layout panels in WPF
1] Stack Panel
2] Dock Panel
3] Wrap Panel
4] Grid Panel
5] Canvas Panel
1] Stack Panel: It stacks all its child elements below or beside each other depending up on the horizontal or vertical orientation. Whenever user wants to create any list, this layout is useful. For internal layout panel, combo box, list box or menu use stack panel.
2] Dock Panel: It provides an easy docking of elements to the left, right, top, bottom or center of panel. The dock side of an element is defined by the attached property DockPanel.Dock
To dock an element to the center of the panel, it must be the last child of the panel and the LastChildFill property must be set to true.
3] Wrap Panel: It is similar to stack panel but it does not just stack all child elements to one row, it wraps them to new lines if no space is left. The orientation can be set to Horizontal or Vertical.
It can be used to arrange tabs of a tab control, menu items in a toolbar or items in a Windows Explorer like list.
It is often used with items of the same size.
4] Grid Panel : It is used to arrange children within a grid.
It can be defined through ColumnDefinition and RowDefinition objects.
It has tabular layout hence you can visualize HTML tables while using grid layout.
It handles resizing. It works as a container for all other elements.
It is used to add controls to grid through attached properties Grid.Row , Grid.Column
Uniform grids can be used where all cells are required to be of same size.
5] Canvas Panel : It is considered as basic layout in WPF. Its child elements are positioned by explicit coordinates. The coordinates can be specified relative to any side of the panel using Canvas.Left, Canvas.Top, Canvas.Bottom and Canvas.Right attached properties.