单击列表框项目时是否可以移动到下一个全景项目页面?
我在下面尝试了这个,但它给了我一个只读错误
编辑:我已经想出如何实现这一目标,但它设置的背景图像与第一个项目中显示的相同,是否有人知道解决此问题的方法?
private void myListBox_Tap(object sender, GestureEventArgs e)
{
pano.SelectedItem = 1;
}
PanoramaPage1.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>
感谢您的帮助
答案 0 :(得分:2)
找到我的答案here
我需要MyPanorama.DefaultItem = MyPanorama.Items[1];
答案 1 :(得分:0)
抱歉,SelectedIndex和SelectedItem是只读的。我所知道的唯一解决方法是设置DefaultItem,如下所示:
pano.DefaultItem = myPanoramaItem;
这一切都很难看,因为它没有动画。另一方面:我认为控制本来不是以这种方式使用的。我只使用这种方式设置当前项目,当返回到想到后退按钮或从睡眠中来的页面时。