Windows phone 7 以编程方式移动到列表框点击上的下一个全景项目

Windows phone 7 以编程方式移动到列表框点击上的下一个全景项目,windows-phone-7,Windows Phone 7,单击列表框项目时是否可以移动到下一个全景项目页面 我在下面尝试过这个,但它给了我一个只读错误 编辑:我已经想出了如何实现这一点,但它将我的背景图像设置为与第一项中显示的相同,有人知道解决方法吗? private void myListBox_Tap(object sender, GestureEventArgs e) { pano.SelectedItem = 1; } 全景页面1.xaml <!--LayoutRoot contains the root grid wh

单击列表框项目时是否可以移动到下一个全景项目页面

我在下面尝试过这个,但它给了我一个只读错误

编辑:我已经想出了如何实现这一点,但它将我的背景图像设置为与第一项中显示的相同,有人知道解决方法吗?

private void myListBox_Tap(object sender, GestureEventArgs e)
 {
      pano.SelectedItem = 1;
 }
全景页面1.xaml

<!--LayoutRoot contains the root grid where all other page content is placed-->
<Grid x:Name="LayoutRoot">

    <controls:Panorama Name="pano" Title="Trending Now" ItemsSource="{Binding}" FontSize="12">

        <!--Assigns a background image to the Panorama control.-->
        <controls:Panorama.Background>
            <ImageBrush ImageSource="/TrendApp;component/Images/pan.png" />
        </controls:Panorama.Background>
        <controls:Panorama.TitleTemplate>
        <DataTemplate>
                    <TextBlock Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" FontSize="100" Margin="0,50,0,0" />
                </DataTemplate>
            </controls:Panorama.TitleTemplate>
        <controls:Panorama.HeaderTemplate >
            <DataTemplate>
                <TextBlock Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" FontSize="40" Margin="0,50,0,0" />
            </DataTemplate>
        </controls:Panorama.HeaderTemplate >

        <!--Panorama item one-->

        <controls:PanoramaItem Name="p1" Header="Trends">
            <Grid>

                <ListBox ItemsSource="{Binding Trend}"  Foreground="White" Height="494" HorizontalAlignment="Center" Margin="2,12,-13,0" Name="myListbox" VerticalAlignment="Top" Width="431"  TabIndex="10" Tap="myListBox_Tap">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Margin="0,0,0,10" TextWrapping="Wrap" FontSize="26" Foreground="White" HorizontalAlignment="Left" Name="tblTrend" Text="{Binding TrendItemTag}" VerticalAlignment="Top" />
                                <TextBlock Margin="0,0,0,10" TextWrapping="Wrap" FontSize="26"  HorizontalAlignment="Right" Name="tblTrend2" Text=">" VerticalAlignment="Top" />

                                <Line X1="0" X2="500" Y1="0" Y2="0" VerticalAlignment="Bottom" Fill="White" Opacity="1" Stroke="White" StrokeThickness="3" Margin="0" />
                            </Grid>
                        </DataTemplate>

                    </ListBox.ItemTemplate>
                </ListBox>

            </Grid>
        </controls:PanoramaItem>

        <!--Panorama item two-->
        <controls:PanoramaItem Name="item2" Header="" FontSize="10">

            <Grid/>
        </controls:PanoramaItem>
        <!--Panorama item three.-->
        <controls:PanoramaItem Header="Search">
            <Grid>
                <TextBox Height="75" HorizontalAlignment="Left" Margin="96,12,0,0" Name="textBox1" Text="Search" VerticalAlignment="Top" Width="235" />
            </Grid>
        </controls:PanoramaItem>
    </controls:Panorama>
</Grid>


感谢您的帮助

对不起,SelectedIndex和SelectedItem是只读的。我所知道的唯一解决方法是如下设置DefaultItem:

pano.DefaultItem=myPanoramaItem

这一切都很丑陋,因为它不做动画。另一方面:我认为控件从来没有打算这样使用。我只在返回页面时使用这种设置当前项目的方法,我认为返回按钮或从睡眠中恢复。

找到了我的答案


我需要
MyPanorama.DefaultItem=MyPanorama.Items[1]

我仍然收到相同的错误,“pano”是我xaml中控件的名称,对吗?``你的MyPanorama项目是整数吗?不,这不起作用。我混淆了全景和轴控制。我的编辑是正确的。正如上面链接中指出的“背景图像将从新的DefaultItem开始”。我如何将其设置为背景图像的中间部分?我不知道。你可以尝试给背景留一个边距,但这需要一些计算才能得到正确的边距,具体取决于图像的大小。再次强调:不要认为控件是通过代码操纵的;在我看来,当返回(返回按钮)或从“睡眠”返回时,这样做的唯一有效原因似乎是。