2011-03-06 56 views
2

我有一個全景控制 XAML佈局:更改照片的運行時間

<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> 

我如何在C#中改變形象samplePhoto.jpg? 感謝

回答

3

片段這樣就可以了:

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

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

<PANORAMA_CONTROL>.Background = b; 

的BitmapImage能夠下載網上圖片,所以,如果有可用通過網站/服務的圖片,你可以通過直接鏈接到它的URL。