Introduction to Windows 8 style application development 17 layout control

Source: Internet
Author: User
Tags relative

The Panel class is an important class in the development of Windows 8 store applications, and it plays a very important role in the Windows 8 store application layout system.

A panel can host multiple child elements, which can be stored in the stack, or in the grid, or at the edges of the handle elements.

The Panel class itself is an abstract class, and the following is the hierarchy of the Panel class:

The three standard layout controls included in the Windows 8 store application: Canvas (usually in a regular layout, try not to consider using Canvas, but in some special cases, Canvas is very handy), Grid (which is preferred for most general layouts), StackPanel (probably the simplest kind of panel type).

Canvas

To locate an element in canvas, you need to provide the horizontal and vertical coordinates relative to the upper-left corner.

Code implementation effect:

Where the left and top properties represent the relative position of the upper-and upper-left corner of the element and canvas.

Generally speaking, canvas is more suitable for the layout of elements in any location, so it is more suitable for vector graphics programming than control layout programming.

Similarly, we control the layout of control elements in canvas in C # code.

We note that the left and top properties of the button are not set in the XAML code, which is set through the C # code, as opposed to canvas.

The SetValue method is defined within the DependencyObject class, where Leftproperty and Topproperty are static fields of the canvas type in DependencyProperty.

The final implementation of the two layout settings is the same.

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.