Windows Phone 8 Primary Tutorial (v) Layout and Event Basics

Source: Internet
Author: User
Tags opening and closing tags relative first row

Original address:

Http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-5-Basics-of-Layout-and-Events

Series Address: Http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners

Source code: HTTP://AKA.MS/ABSBEGINNERDEVWP8

PDF version: Http://aka.ms/absbeginnerdevwp8pdf

I'll discuss the layout in this lesson, in other words, how to locate or arrange controls on the user interface of the application.

The plan for this lesson is:

We will discuss two main elements for layout and positioning: Grid and StackPanel.

For grid, I'll discuss options and techniques for defining rows and columns and various resizing to take full advantage of grid functionality.

Next, we'll learn about StackPanel and adjust the application from grid layout to StackPanel layout, which will teach us some key differences between grid and StackPanel.

Finally, we'll discuss how event handlers can "connect" in XAML and C #.

1. Understanding the basics of grid

The default Windows Phone page template creates a <Grid> element called "Contentpanel."

The grid element is used for the layout of other controls. It allows you to define rows and columns, and each control can request which row and column it is placed in.

The default Windows Phone page template creates a <Grid> element called "Contentpanel."

In the default MainPage.xaml page template, the Grid appears empty between opening and closing tags <Grid></Grid>, and it does not seem to have a row or column definition. However, even if they are not explicitly defined, there is always a row definition and a column definition by default. They occupy all the available vertical and horizontal spaces to represent a large "unit" in the grid. Any project placed between the start and end <Grid></Grid> elements is considered to be in this implicit "unit".

2. Grid's row definition (rowdefinitions) and column definition (columndefinitions) and definition size

The "LayoutRoot" grid is a grid that defines rows. The grid defines two lines:

Note that the stackpanel containing the item and the page title places itself in the first row, which has a property called grid.row= "0". You use a zero-based numbering scheme to refer to rows and columns.

Note by setting the property grid.row= "1", the Content Panel grid (contentpanel grid) places itself in the second row.

The first row is set to Automatic (auto). The second line (line 1) is set to "*". There are three kinds of syntax to help you set the size of rows and columns. For XAML layouts, the height and width are relative and are affected by many factors. The layout engine considers all of these factors to determine the actual position of the item on the page.

For example, "Auto" means that the row is high enough to hold all the controls placed in it. If the highest control height is 150 pixels, then this is the actual height of the row. If it's only 100 pixels, then that's the height of the row. Therefore, "automatic" indicates that the height is a control within the relative row.

The star is called proportional scaling, which means that the height of the row should occupy all the remaining available heights.

Here is another simple example that uses scale scaling. I created a project that has a definition for three rows in the content panel. Please note the height of each line:

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

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.