Windows phone 7 枢轴控制错误
我目前正在编写一个涉及在pivot控件之间导航的应用程序 总共将有8个枢轴。我已经做了一个,目前正在做第二个。但是,当我重复与第一个pivot控件相同的操作时,会出现一个错误。请参阅下面的代码和错误 我是WP7开发的新手。任何帮助都将不胜感激Windows phone 7 枢轴控制错误,windows-phone-7,pivot,Windows Phone 7,Pivot,我目前正在编写一个涉及在pivot控件之间导航的应用程序 总共将有8个枢轴。我已经做了一个,目前正在做第二个。但是,当我重复与第一个pivot控件相同的操作时,会出现一个错误。请参阅下面的代码和错误 我是WP7开发的新手。任何帮助都将不胜感激 using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace SGFoodDirectory
{
public partial class Alcohol : PhoneApplicationPage
{
public Alcohol()
{
InitializeComponent();
}
private void BC_Click(object sender, RoutedEventArgs e)
{
AlPivot.SelectedItem = BcPivot;
}
private void MabukMoney_Click(object sender, RoutedEventArgs e)
{
AlPivot.SelectedItem = MmPivot;
}
}
}
错误:
Microsoft.Phone.Controls.PivotItem' does not contain a definition for 'SelectedItems' and no extension method 'SelectedItems' accepting a first argument of type 'Microsoft.Phone.Controls.PivotItem' could be found (are you missing a using directive or an assembly reference?)
你是说
AlPivot.SelectedItem
而不是AlPivot.SelectedItems
?单击按钮时,以下代码段将从中的第一个透视项导航到第二个透视项
XAML
<controls:Pivot Name="PivotTest" Title="MY APPLICATION">
<controls:PivotItem Name="PI1" Header="item1">
<Grid>
<Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="164,106,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click"/>
</Grid>
</controls:PivotItem>
<controls:PivotItem Name="PI2" Header="item2">
<Grid/>
</controls:PivotItem>
</controls:Pivot>
编辑
啊!!我想我看到了你的问题。您正在尝试设置PivotItem的SelectedItem属性,而不是Pivot控件。如果我没有弄错,您希望在单击按钮时移动到相应的枢轴项目。请不要这样做-枢轴是为用户使用触摸导航而设计的。从看到其他应用程序这样做的经验来看,如果在点击按钮时代码将您跳转到另一个轴心项目,这是非常令人困惑的 此外,拥有8个透视项似乎有点高:这很可能会导致内存使用问题,也可能会导致页面必须翻转8次才能旋转回起始位置的一般可用性问题
我建议您使用其他PhoneApplicationPage重新考虑您的应用程序流程,这样您就不需要这样做。使用“AlPivot.SelectedItem”在重建后也会显示相同的错误。谢谢zombiesheep。不幸的是,它对第一个支点有效。然而,在第二个轴上,上面提到的错误被显示出来。是的,这正是我想要做的。我不明白为什么类似的代码在我的第一个轴上有效,但在第二个轴上无效。嗨,Paul,谢谢你的推荐。透视控件列出了不同的类别和按钮,以帮助用户能够更轻松地导航到透视控件中的项目。ListPixER是一个很好的控件,在这个场景中(在Silverlight工具包中)。因此,我提出的选项在这个案例中是不可行的,不可行的。在阅读了您提出的选项后,我假设您不理解这个问题。将有8个枢轴控制。每个pivot控件将有大约3-4个pivot项。pivots中是否有pivots?请对否决票发表评论。我只是不明白为什么代码在第一个枢轴控件上工作,而在第二个枢轴控件上不工作。任何解释都将不胜感激。
private void button1_Click(object sender, RoutedEventArgs e)
{
PivotTest.SelectedItem = PI2;
}