Silverlight control initialization and layout

Source: Internet
Author: User

https://msdn.microsoft.com/zh-cn/library/dd351483 (v=vs.95). aspx

Control initialization and layout Silverlight

When you create controls, it is important to understand the sequence of initialization and layout events and methods.In this way, you know the correct method to overwrite or the correct event to be handled to get a specific effect.Typically, you can construct a Silverlight control and set its properties, then create its visual representation or visual tree, and then the control goes through the entire layout process. The following table lists the properties that are set during control creation and layout and the events and methods that occur. properties, methods, and events are listed in the order in which they occur.

control properties, methods, or events

Further information

constructs the control.

in XAML, when the start tag for a control declaration is parsed.

-Or-

in code when the constructor is explicitly called.

Control Getting started

Sets the control properties.

In XAML, when an attribute of a control's XAML property is parsed.

Or

In code, when you explicitly set a property.

Getting Started with controls

The style attribute (explicit style) is applied.

In XAML, when

After the end tag of the control is parsed.

Or

In code, when the style property is explicitly set.

Getting Started with controls

style property is applied (the default style from GENERIC.XAML). "The   is applied; the style  property (the default style in Generic.xaml).

 

Loaded event occurs. " > the loaded  event occurs.

When you add an element to the visual tree.   Occurs before the next frame is rendered.   This occurs before any layout operations are performed.

Loaded

Templates are applied (visual elements that create controls based on the template).

During the measurement process of the layout.If you set theThe value of the Template property, the value expands to provide a visual tree. This control is initially created without a visual tree, and the visual tree is cleared when the Template property is set. You can also call ApplyTemplate to expand the template and create a visual tree for the control (if the control does not have a visual tree).

Control customization

OnApplyTemplate method is called. " The   is called; the onapplytemplate  method.

just apply the template for the control.   OnApplyTemplate for the template to be applied; However, inherited types might rely on it for their implementation. " You do not have to invoke basic   when you apply a template, but the inherited type may depend on it for implementation, OnApplyTemplate.

Control customization

The control visualization elements in the code become available for manipulation.

In the OnApplyTemplate. call GetTemplateChild and pass the name of the template part to retrieve.

GetTemplateChild ; visualtreehelper "> GetTemplateChild; visualtreehelper

measureoverride method is called. " The   is called; the measureoverride  method.

During the first layout process, when all children are measured.   measureoverride would be called after the template had been expanded. " If this template is expanded during this measurement processing, &NBSP will be called after the template is expanded; measureoverride.

Silverlight layout system

arrangeoverride method is called. "> called the   arrangeoverride  method.

in arranging the layout process (occurring after the measurement process).

Silverlight layout system

SizeChanged event is raised. " >   sizechanged  event.

After both of these layout processes (measurements and permutations) have been completed.

Silverlight layout system

Raises the LayoutUpdated event.

If the SizeChanged event occurs.

Silverlight control initialization and 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.