2012-10-18 127 views
0

我有一個小問題,我想改變我的應用程序的背景與C#。 我試過這段代碼:背景圖像Windows Phone 7

var app = Application.Current as App; 
var imageBrush = new ImageBrush 
{ 
ImageSource = new BitmapImage(new Uri(imageName, UriKind.Relative)) 
}; 
app.RootFrame.Background = imageBrush; 

但它不工作,背景是暗..我試圖做的:

app.RootFrame.Background = new SolidColorBrush(Colors.Blue); 

而且效果很好。所以,我不明白問題出在哪裏,我的形象是480×800像素和我設置生成操作內容複製到輸出目錄複製如果新

感謝所有

+0

使用的ImageBrush設置圖像作爲backgorund –

回答

1

也許你可以試試

 var app = Application.Current as App; 
     if (app == null) 
      return; 

     var imageBrush = new ImageBrush 
     { 
     }; 
     var uu = new BitmapImage(new Uri(imageName, UriKind.Relative)); 
     uu.CreateOptions = BitmapCreateOptions.None; 
     imageBrush.ImageSource = uu; 

     app.RootFrame.Background = imageBrush; 

馬克:uu.CreateOptions = BitmapCreateOptions.None;

0

我成功做幾乎同樣的事情用一個形象,但我設置圖像爲背景,以一個全景的控制。我知道其他人遇到了與this post相同的問題,所以我建議設置LayoutRoot或其他控件的背景,而不是app.RootFrame。

0

謝謝你們倆!

我以前曾經單獨嘗試過兩種解決方案,但沒有奏效。但它們一起工作完美!

的代碼:

var imageBrush = new ImageBrush 
{ 
}; 
var uu = new BitmapImage(new Uri("/Images/image.png", UriKind.Relative)); 
uu.CreateOptions = BitmapCreateOptions.None; 
imageBrush.ImageSource = uu; 

LayoutRoot.Background = imageBrush; 
相關問題