[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