简体   繁体   中英

How does the WP7 Pivot control dynamically load pivot items?

IIRC, the Pivot control only loads a child PivotItem if it is the currently shown child. I would then guess that the previously seen child is also somehow unloaded, presumably still stored in memory, but hidden from the UI.

What I'm wondering is, how does the Pivot control dynamically load/unload a child control, and can that behavior be imitated within a custom UserControl? As for unloading, is it as simple as collapsing the previous child's visibility, or is something trickier going on?

That is to say, supposing I use my own UserControl like:

 <my:CustomUserControl>
   <TextBlock x:Name="_textBlock" Text="wait for it ..." />
 </my:CustomUserControl>

Normally, the child TextBlock is instantiated when the surrounding PhoneApplicationPage is instantiated, via InitializeComponent and all that. Is there any way to postpone this behavior and load the child programmatically?

Easy way to achive your goal is to use ContentControl with template. It will create all controls only after setting Contenp property. Or you can simply inherit your control from Panel and add child controls in code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM