Reputation: 3455
Is it possible to move to the next panorama item page when a Listbox item is clicked?
I have tried this below but its giving me a read only error
EDIT: I have figured out how to achieve this but it is setting my background image the same as it would appear in the first item, does anyone know of a way around this?
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>
Thanks for your help
Upvotes: 1
Views: 1587
Reputation: 50672
Sorry, the SelectedIndex and SelectedItem are readonly. The only workaround that I know of is setting the DefaultItem like this:
pano.DefaultItem = myPanoramaItem;
This is all pretty ugly because it doesn't do the animation. On the other hand: I don't think the control was ever meant to be used this way. I only use this way of setting the current item when returning to the page thought the back-button or getting coming from sleep.
Upvotes: 0