Silverlight Layout System

Source: Internet
Author: User

I,SilverlightLayout System

1.SilverlightPlug-in location and size

SilverlightApplicationProgramInHtmlLocation in the host, locateSilverlightThere are two reference frameworks:

Plugin:SetSilverlightObjects on the drawing are located in the boundary of the plug-in.

HtmlInternal:The entire plug-in and all objects in it areHtml.

2.Layout System

LayoutOne-word description is based onSilverlightThe process of adjusting the object size and locating the object in the application.

Parent PanelModerateChildrenWhen each element'sUielementWhen the location is changed, the layout system may trigger a new processing process.

Layout is a recursive system that allows you to adjust, locate, and draw elements on the screen. The layout system is ChildrenEach member of the Set completes two processing processes: the first is the measurement processing process, and the second is the arrangement processing process. The measurement processing process is the process of determining the size required for each sub-element. The arrangement process is the process of determining the size and position of each sub-element.

To override the default Panel For each type panel you must provide your own measureoverride and arrangeoverride method to implement specific layout behavior. When the layout system is called, the following series of events occur:

1.Measure each sub- Uielement.

2. Computing On Frameworkelement For example Width,HeightAnd Margin.

3. application panel specific logic, such as stack orientation .

4.Measure all sub-elements and arrange the content.

5.ChildrenSet to draw to the screen.

6. if other children added to the collection, children Layout attributes (for example, width and heigh ) changed or called updatelayout This process is called again.

3.Element border box(This issue cannot be easily clarified)

Based onSilverlightAll elements in the application are surrounded by a boundary box. When the layout system locates any FrameworkelementIn fact, it is positioning the rectangle or layout slot containing the element.

The layout slot size of each child element is determined by the parent container.

4.Measure and arrange child elements

During the measurement process, the layout system will tell Panel Its Availablesize (Available size) , Panel The local size attribute of each of its child elements is calculated, as shown in figure Clip And Visibility . Next, process frameworkelement attribute. These attributes are designed to describe the basics uielement size adjustment feature, such as height , width , margin and style . Then, panel calls each of its child elements measure method to pass the available size of the corresponding child element.

the final goal of the measurement processing process is to let the layout system determine each sub-element desiredsize , this is called measure occurs internally.

In Height,Width,ActualheightAnd ActualwidthThere are differences between attributes. For example,ActualheightAttribute is calculated based on other height input and layout systems.

During the arrangement process, the layout system will tell panel finalsize . Parent panel the element calculates the desiredsize and any other margins that may affect the rendering size of the element, and determine the border boxes of each child element. The size of the layout slot of the stator element. Then, the parent panel call arrange method, to pass the rect .

5.PanelElement and custom Layout

Canvas explicitly locates child elements. (Absolute positioning)

A grid defines a flexible grid area consisting of rows and columns.

Stackpanel arranges child elements in one row (either horizontally or vertically ).

Common attributes:Margin horizontalalignment canvas. zindex

No width or height is defined for the root element or layout element.,YesDomThe width and height attributes of are retained100%

<Usercontrol X: Name = "rootelement" X: class = "windowresizingsample. Page"

Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"

Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml">

<Grid X: Name = "layoutroot" background = "white">

 

</GRID>

</Usercontrol>

 

II,Custom panel

Canvas, stackpanel, gridWhen you cannot meet your layout requirementsPanelDerive and override itMeasureoverrideAndArrangeoverrideMethod.

1.Measurement

Protected override size measureoverride (size availablesize)

{

Int I = 0;

Foreach (frameworkelement child in children)

{

Child. Measure (new size (100,100 );

I ++;

}

 Return new size (300,300 );

}

In MeasureoverrideMust call MeasureMethod to pass the space that can be allocated to the Panel

2.Arrange

After the measurement processing is completed, the sorting process starts. During the arrangement process, you must determine the location and size of each sub-level layout slot and set the final size of the Panel.

In Arrangeoverride, For each sub-level call Arrange, Transfer Rect. It sets the origin, height, and width of the Child-level layout slot of the parent panel.

3.Scrolling content and performance

If you create a custom control that contains many scrollable content (similar ListBox), And the control loading process is slow or the scrolling is not smooth, consider using virtualization."Virtualization"A technology that generates data from a large number of data items based on the items displayed on the screen.UIA subset of elements.

III,Full Screen support

1.Enter full screen mode

When you IsfullscreenSet property True Time, based onSilverlightThe application enters full screen mode.

The followingCodeThe example shows how to switch IsfullscreenAttribute Value to enable or disable full screen mode.

SilverlightThe dialog box is not supported in full screen mode.

Full Screen mode does not support drag-and-drop or multi-touch input.

WhenSilverlightWhen the application is in full screen mode, most Keyboard Events are prohibited.

Switching between the embedded mode and the full screen mode has little impact on the performance of the content contained in the application. This means that in most cases, the playing of audio or video content is completely continuous.

WindowlessSet property True OfSilverlightWhen the plug-in is displayed in full screen mode, it always draws its background color in a completely opaque manner.

IV,SilverlightAlignment in the designer

1.Alignment is a visual prompt that helps you set the alignment of a widget relative to other controls in the application.

2.MarginIs the size of space between the edge of the control and the edge of the host container

3.Grid lines can be used inSilverlightUse alignment in the designer GridControl of Container Control Arrangement

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.