Wp8.1 UI programming III. Layout

Source: Internet
Author: User

1. Panel is the parent class of all layout panels. Common Layout panels:

Canvas. child elements can be located based on the coordinates of the region.

Stackpanel, stack panel, layout structure is like a stack, only horizontal and vertical direction.

Grid, grid, and sub-elements can be laid out based on the row and column layout.

If Complex layout is not required, use a relatively simple layout panel to improve performance. For example, use canvas instead of grid.

The layout is a recursive system that first performs measurements and then arranges them. Measurement refers to the size and position of the final child element.

Relayout should be minimized to improve performance.

The UI element has two important classes: uielement and frameworkelement. The Inheritance structure is as follows:

Windows. UI. XAML. dependencyobject

Windows. UI. XAML. uielement: Has the measure and arrange methods.

Windows. UI. XAML. frameworkelement: has two virtual Methods: measureoverride and arrangeoverride.

Recursion of measurement and arrangement:

Call measure and arrange successively;

Measure first calls measureoverride (if this method is implemented). If the element has a sub-object, measureoverride then calls the sub-object's measure;

Arrange first calls arrangeoverride (if this method is implemented). If the element has a sub-object, arrangeoverride then calls the sub-object arrange.

 

Deploy different resolutions to avoid the number of hardcoded workers.

You can also use the height and width attributes of the windows. UI. XAML. Window. Current. bounds class to obtain the resolution and proportion of the mobile phone, so as to dynamically adapt to the actual resolution.

 

2. Based on the above, you can customize layout rules.

Inherit the Panel to customize the layout panel.

If some parameters are passed to implement a special layout (for example, the circle surrounding layout requires a radius value), use the invalidatearrange method to rearrange the layout dynamically according to the parameter changes.

Override the measureoverride and arrangeoverride methods.

Wp8.1 UI programming III. Layout

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.