Advertisement
Guest User

Untitled

a guest
Apr 25th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. SelectionChanged Event for ListBox in panorama.ItemTemplate for Windows Phone?
  2. <phone:PhoneApplicationPage.Resources>
  3. <CollectionViewSource x:Key="SlideItemList" Filter="collectionView_Filter"/>
  4. </phone:PhoneApplicationPage.Resources>
  5.  
  6. <!--LayoutRoot is the root grid where all page content is placed-->
  7. <Grid x:Name="LayoutRoot" Background="Transparent">
  8.  
  9. <!--Panorama control-->
  10. <controls:Panorama x:Name="AppPano" ItemsSource="{Binding SlidesCollections}" SelectionChanged="AppPano_SelectionChanged" >
  11. <controls:Panorama.Background>
  12. <ImageBrush ImageSource="PanoramaBackground.png"/>
  13. </controls:Panorama.Background>
  14.  
  15. <controls:Panorama.ItemTemplate>
  16. <DataTemplate>
  17. <Grid VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,-100,0,0">
  18. <StackPanel HorizontalAlignment="Center" Height="250" Width="200" VerticalAlignment="Top">
  19. <TextBlock Text="{Binding Title}" HorizontalAlignment="Center" FontSize="200" Width="Auto"/>
  20. </StackPanel>
  21. <ListBox x:Name="ItemsList" ItemsSource="{Binding Source={StaticResource SlideItemList}}" Margin="0,250,0,0" VerticalAlignment="Top" SelectionChanged="ItemsList_SelectionChanged" Height="430">
  22. <ListBox.ItemTemplate>
  23. <DataTemplate>
  24. <StackPanel x:Name="ImgStack" HorizontalAlignment="Left" Height="430" VerticalAlignment="Top" Width="370" Margin="50,0,0,0">
  25. <Image Height="350" Width="360" Source="{Binding Image}"/>
  26. </StackPanel>
  27. </DataTemplate>
  28. </ListBox.ItemTemplate>
  29. </ListBox>
  30. </Grid>
  31. </DataTemplate>
  32. </controls:Panorama.ItemTemplate>
  33. </controls:Panorama>
  34. </Grid>
  35.  
  36. private void keyItemsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
  37. {
  38. var listbox = (ListBox)sender;
  39. var conGen = listbox.ItemContainerGenerator;
  40. var item = (UIElement)conGen.ContainerFromIndex(listbox.SelectedIndex);
  41.  
  42. if (item != null)
  43. {
  44. int selectedItemList = listbox.SelectedIndex;
  45. if (sLasListItem != selectedItemList)
  46. {
  47. // navigate to another page
  48. sLasListItem = selectedItemList;
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement