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
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.
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)
精彩评论