Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何为windows phone 7应用程序设置背景图像_C#_Windows Phone 7 - Fatal编程技术网

C# 如何为windows phone 7应用程序设置背景图像

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

我想为Windows Phone 7的整个应用程序设置背景图像。我猜图像的大小应该是480 x 800,我已经知道了


应该在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}">


您的图像应显示在应用程序的所有页面上

我应该在哪里调用此方法?我应该在哪里调用此方法?