如何使用 WP7 Panorama 和 Windows Phone 7 选择特定的 PivotItem枢轴控制?
我已经开始使用 Windows Phone 7 Panorama & Windows Phone 7 应用程序的旋转控件。在 OnNavigedTo 事件中,我尝试选择要在其上启动新视图的 PivotItem。所有 SelectedItem
和 SelectedIndex
似乎都是选择标题。未显示 PivotItem 的内容,并且在选择标题时,手机未对其进行动画处理。这是我当前的实现:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// URI is '/page/PivotItemToSelect'.
string selectedPivotItem = e.Uri.OriginalString.Split('/').Last();
// Match PivotItemToSelect with the PivotItem's Name.
PivotItem pivotItemToShow = MainPivotControl.Items.Cast<PivotItem>().Single(i => i.Name == selectedPivotItem);
MainPivotControl.SelectedItem = pivotItemToShow;
base.OnNavigatedTo(e);
}
我也尝试过:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// URI is '/page/PivotItemIndex'.
string selectedPivotItemIndex = e.Uri.OriginalString.Split('/').Last();
int index = int.Parse(selectedPivotItemIndex);
MainPivotControl.SelectedIndex = index;
base.OnNavigatedTo(e);
}
这两种实现都执行我上面描述的操作。我是否在选择过程中错过了一个步骤,尝试在页面生命周期中太晚选择数据透视项,或者此版本的控件尚不支持预选?
I have started using the Windows Phone 7 Panorama & Pivot Controls for a Windows Phone 7 application. In an OnNavigatedTo event, I'm trying to select which PivotItem to start the new View on. All SelectedItem
and SelectedIndex
seem to do is select the header. The content of the PivotItem is not shown and while the header is selected the phone has not animated to it. Here is my current implementation:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// URI is '/page/PivotItemToSelect'.
string selectedPivotItem = e.Uri.OriginalString.Split('/').Last();
// Match PivotItemToSelect with the PivotItem's Name.
PivotItem pivotItemToShow = MainPivotControl.Items.Cast<PivotItem>().Single(i => i.Name == selectedPivotItem);
MainPivotControl.SelectedItem = pivotItemToShow;
base.OnNavigatedTo(e);
}
I have also tried:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// URI is '/page/PivotItemIndex'.
string selectedPivotItemIndex = e.Uri.OriginalString.Split('/').Last();
int index = int.Parse(selectedPivotItemIndex);
MainPivotControl.SelectedIndex = index;
base.OnNavigatedTo(e);
}
Both of these implementations do what I described above. Am I missing a step in the selection process, trying to select a PivotItem too late in the lifecycle of the page, or does this version of the controls not yet support preselection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些工具的正式发布已经解决了这个问题。现在已正确选择 PivotItem。
The official release of these tools has fixed the issue. The PivotItem is now selected correctly.