Wpf ui Layout (Layout) WPF Reading Notes (Third Day)

Source: Internet
Author: User

The layout elements of WPF are as follows:

  • Grid: Grid. You can customize rows and columns and adjust the layout of the control by the number of columns, row height, and column width.
  • StackPanel: Format panel. You can arrange the elements in the horizontal or vertical direction into a line.
  • Canvas: Canvas. Controls placed on the canvas are located with absolute coordinates.
  • DockPanel: Parking panel. You can select the direction of the internal element.
  • WrapPanel: auto-folding panel. When an internal element is filled with a row, it is automatically folded.

 

The following mainly records DockPanel, because it is the most difficult to understand during the reading process.

All elements in the DockPanel are appended with the DockPanel. Dock attribute. The data type of this attribute is the Dock enumeration. The Left, Top, Right, and Bottom values can be used in the Dock enumeration. It has a very important property-bool type LastChildFil, which defaults to True. In this case, DockPanel. Dock will fill up the remaining DockPanel controls.

The following is a simple example of a DockPanel:

<Window x:Class="DockPanel.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="MainWindow" Height="350" Width="525">    <Grid>        <DockPanel>            <TextBox  Text="Top" DockPanel.Dock="Top" Height="25" BorderBrush="Black"/>            <TextBox Text="Left" DockPanel.Dock="Left" Width="150" BorderBrush="Black"/>            <TextBox Text=" LastChild" BorderBrush="red"/>        </DockPanel>    </Grid></Window>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.