WPF notes (1.4 layouts)--hello,wpf!

Source: Internet
Author: User

Original: WPF notes (1.4 layouts)--hello,wpf!

This section is only the 2nd chapter of the Primer.
Layout to use the Panel control, there are four kinds of panel, as follows:
DockPanel, is to set the docking location layout model.
StackPanel, which provides a stack model for placing content from left to right or from top to bottom.
Grid, which provides a model that allows row/grid positioning. Tables can be used.
Canvas for precise positioning.

The grid is the most commonly used, and the vs2005 automatically generated page and window have this label by default:

Example1- -. A sample usage of the Grid panel
<Window>
<Grid>
<grid.rowdefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</grid.rowdefinitions>
<grid.columndefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</grid.columndefinitions>
<Button Grid.Row="0"Grid.column="0"Grid.columnspan="2">A</Button>
<Button Grid.Row="0"Grid.column="2">C</Button>
<Button Grid.Row="1"Grid.column="0"Grid.rowspan="2">D</Button>
<Button Grid.Row="1"Grid.column="1">E</Button>
<Button Grid.Row="1"Grid.column="2">F</Button>
<Button Grid.Row="2"Grid.column="1">H</Button>
<Button Grid.Row="2"Grid.column="2">I</Button>
</Grid>
</Window>This procedure produces a 3x3 table. Note that you first define the row format, define the column format, and finally put the button into the cell.

Example1- -. Arranging an image and textincha grid
<Button Width=" -"Height=" -">
<button.content>
<Grid>
<grid.rowdefinitions>
<RowDefinition/>
<RowDefinition/>
</grid.rowdefinitions>
<Image Grid.Row="0"Source="Tom.png" />
<TextBlock
Grid.Row="1"
HorizontalAlignment="Center">Tom</TextBlock>
</Grid>
</button.content>
</Button>This program is added to the picture below a line of caption, is also used under the grid table layout.

The above two examples have grid.row=1 such a grammar--Attached-property the implicated attribute. That is, define () inside the grid and specify the property value in the External control button.
The purpose of the implicated attribute is not necessarily to fill the cell with a button beforehand, so that it is arbitrary for all controls-temporarily, because you don't see Chapter two.

WPF notes (1.4 layouts)--hello,wpf!

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.