我想为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