简体   繁体   English

WP7数据透视控件如何动态加载数据透视项?

[英]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. IIRC,Pivot控件仅在当前显示的子项时才加载子项PivotItem。 I would then guess that the previously seen child is also somehow unloaded, presumably still stored in memory, but hidden from the UI. 然后,我猜想以前看到的孩子也以某种方式被卸载了,大概仍然存储在内存中,但是对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? 我想知道的是,Pivot控件如何动态加载/卸载子控件,并且该行为可以在自定义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: 也就是说,假设我使用自己的UserControl像这样:

 <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. 通常,当实例化周围的PhoneApplicationPage时,将通过InitializeComponent以及所有这些实例化子TextBlock。 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. 实现目标的简单方法是将ContentControl与模板一起使用。 It will create all controls only after setting Contenp property. 仅在设置Contenp属性后,它将创建所有控件。 Or you can simply inherit your control from Panel and add child controls in code. 或者,您可以简单地从Panel继承控件,然后在代码中添加子控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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