trickui
trickui

Reputation: 297

Change photo in Panorama run time

I have a Panorama control xaml layout is :

<Grid x:Name="LayoutRoot">

    <controls:Panorama Title="my application">  v
         <!--Assigns a background image to the Panorama control.-->
         <controls:Panorama.Background>
         <ImageBrush ImageSource="samplePhoto.jpg"/>
         </controls:Panorama.Background>
               <!--Panorama item one-->
               <controls:PanoramaItem Header="item1">
                <Grid/>
               </controls:PanoramaItem>

How i can change image samplePhoto.jpg in c#? thank

Upvotes: 2

Views: 1062

Answers (2)

decyclone
decyclone

Reputation: 30830

Here is a good post by Jeff Wilcox to that shows how to do that:

WP7 Panorama: Smoothly fading the background (and enabling fading when changing, too)

Upvotes: 3

Den
Den

Reputation: 16826

A snippet like this will do the trick:

BitmapImage image = new BitmapImage(new Uri("IMAGE_URI",UriKind.Absolute));

ImageBrush b = new ImageBrush();
b.ImageSource = image;

<PANORAMA_CONTROL>.Background = b;

BitmapImage is able to download online images too, so if there is an image that is available through a web site/service, you can pass the URL to it directly.

Upvotes: 3

Related Questions