我想爲Windows Phone 7的整個應用程序設置一個背景圖片。我想圖片的大小應該是480 x 800,這已經是我的了。如何爲windows phone 7應用程序設置背景圖片
它應該在App.xaml或WMAppManifest.xaml中設置嗎?如果是這樣,請將我指向代碼示例。
我想爲Windows Phone 7的整個應用程序設置一個背景圖片。我想圖片的大小應該是480 x 800,這已經是我的了。如何爲windows phone 7應用程序設置背景圖片
它應該在App.xaml或WMAppManifest.xaml中設置嗎?如果是這樣,請將我指向代碼示例。
無法全局設置背景圖像。您需要爲每個頁面設置它。
您是否試過這種方式?
private static void SetAppBackground(string imageName)
{
var app = Application.Current as App;
if (app == null)
return;
var imageBrush = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(imageName, UriKind.Relative))
};
app.RootFrame.Background = imageBrush;
}
我不認爲你需要爲每個頁面設置一個背景圖像。如果這個片段添加到的App.xaml:
<ImageBrush x:Key="imgKey" ImageSource="/Images/imgName.png" />
而且在MainPage.xaml中更改網格配置:
<Grid x:Name="LayoutRoot" Background="{StaticResource imgKey}">
您的圖片應該在你的應用程序的所有頁面上顯示。
我應該在哪裏調用這個方法? – bragboy
在你的page.xaml中 – coder