X:deferloadstrategy of "WIN10" uap/uwp/general development

Source: Internet
Author: User

[Some information relates to pre-released product which could be substantially modified before it ' s commercially released. M Icrosoft makes no warranties, express or implied, with respect to the information provided here.]

[The version involved in the pre-release of a message may be substantially modified in its commercial version.] Microsoft makes no warranties regarding the information provided herein. ]

First, X:deferloadstrategy

Lazy<t> Everyone is familiar with, that is, delay loading, the use of the time to load the corresponding pair of images,deferloadstrategy and lazy<t> is similar. The interface is loaded without loading this control until you go to the manual call.

It is now known that there are two ways to load a control, one is FindName and the other is Gettemplatechild.

Second a simple example

        <RelativepanelHorizontalAlignment= "Center">            <Buttonx:name= "_btnload"Content= "Load"HorizontalAlignment= "Left"VerticalAlignment= "Top"Click= "Button_Click" />            <Rectanglex:name= "_lasyrect"Width= "+"Height= "+"Fill= "Red"X:deferloadstrategy= "Lazy"Relativepanel.rightof= "_btnload" />        </Relativepanel>
Private void Button_Click (object  sender, RoutedEventArgs e) {    ifnull)    {          This . FindName (nameof (_lasyrect));}    }

The effect shown is this, no rectangle

If it's just not showing, it doesn't really mean anything, let's take a look at the visual tree.

You can spit it out here, VS2015 the tools to view the visual tree into VS , and deeply mourn for tools like the Xaml Spy .

This position has only one buttonand no Rectangle. is not in front of the light. Let's click.

It came out in a sudden.

Third, the application scenario

Think about where we can use it.

1, first think of is the custom control ah, many people like to write a control, but which value is not empty when the display of which, the previous use is collapsed, now can not be loaded with Ben.

2, loading pictures, sometimes we will load a lot of web images, but there may be some data is no picture, but also to load the image control over there is not very good (can actually be used to switch data template processing).

This address: http://www.cnblogs.com/gaoshang212/p/4561595.html

X:deferloadstrategy of "WIN10" uap/uwp/general development

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.