Wpf 简明教程
WPF - Layouts
控件的布局对于应用程序可用性非常重要、关键。它用于组织应用程序中的 GUI 元素组。选择布局面板时需要考虑某些重要问题 −
The layout of controls is very important and critical for application usability. It is used to arrange a group of GUI elements in your application. There are certain important things to consider while selecting layout panels −
-
Positions of the child elements
-
Sizes of the child elements
-
Layering of overlapping child elements on top of each other
当应用程序在不同的屏幕分辨率上时,控件的固定像素排列不起作用。XAML 提供了一组丰富的内置布局面板,以合适的方式排列 GUI 元素。下面列出了一些最常用、最流行的布局面板 −
Fixed pixel arrangement of controls doesn’t work when the application is to be sed on different screen resolutions. XAML provides a rich set of built-in layout panels to arrange GUI elements in an appropriate way. Some of the most commonly used and popular layout panels are as follows −
Sr. No. |
Panels & Description |
1 |
Stack PanelStack panel is a simple and useful layout panel in XAML. In stack panel, child elements can be arranged in a single line, either horizontally or vertically, based on the orientation property. |
2 |
Wrap PanelIn WrapPanel, child elements are positioned in sequential order, from left to right or from top to bottom based on the orientation property. |
3 |
Dock PanelDockPanel defines an area to arrange child elements relative to each other, either horizontally or vertically. With DockPanel you can easily dock child elements to top, bottom, right, left and center using the Dock property. |
4 |
Canvas PanelCanvas panel is the basic layout panel in which the child elements can be positioned explicitly using coordinates that are relative to the Canvas any side such as left, right, top and bottom. |
5 |
Grid PanelA Grid Panel provides a flexible area which consists of rows and columns. In a Grid, child elements can be arranged in tabular form. |