Search code examples
windows-phone-7windows-phone-7.1panorama-control

Change background image on panorama on WP7 when user scrolls across


Just wondering if anyone knows of a way to change the panorama background image dynamically when the user scrolls across on windows phone 7?


Solution

  • On the Xaml do:

         <controls:Panorama Title="my application" SelectionChanged="Panorama_SelectionChanged">
            <controls:Panorama.Background>
                <ImageBrush x:Name="myImg" ImageSource="PanoramaBackground.png"/>
            </controls:Panorama.Background>
            ...
            ..
            . // your code
    

    To change the Image at code behind use:

         private void Panorama_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             myImg.ImageSource = new BitmapImage(new Uri("Jellyfish.jpg", UriKind.Relative));
         }
    

    Its working for me. Hope it helps you too.