C# 如何为windows phone 7应用程序设置背景图像
我想为Windows Phone 7的整个应用程序设置背景图像。我猜图像的大小应该是480 x 800,我已经知道了C# 如何为windows phone 7应用程序设置背景图像,c#,windows-phone-7,C#,Windows Phone 7,我想为Windows Phone 7的整个应用程序设置背景图像。我猜图像的大小应该是480 x 800,我已经知道了 应该在App.xaml或WMAppManifest.xaml中设置吗?如果是这样,请给我一个代码示例。无法全局设置背景图像。您需要为每个页面设置背景图像。无法全局设置背景图像。您需要为每个页面设置它。您尝试过这种方法吗 private static void SetAppBackground(string imageName) { var app = App
应该在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;
}
你试过这种方法吗
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}">
您的图像应显示在应用程序的所有页面上 我认为您不需要为每个页面设置背景图像。如果将此代码段添加到App.xaml:
<ImageBrush x:Key="imgKey" ImageSource="/Images/imgName.png" />
并将MainPage.xaml中的网格配置更改为:
<Grid x:Name="LayoutRoot" Background="{StaticResource imgKey}">
您的图像应显示在应用程序的所有页面上 我应该在哪里调用此方法?我应该在哪里调用此方法?