bragboy
bragboy

Reputation: 35542

How to set background image for windows phone 7 application

I would like to set a background image for the entire application for Windows Phone 7. I guess the size of the image should be 480 x 800 which I have already.

Should it be set inside App.xaml or WMAppManifest.xaml ? If so, please point me to a code sample.

Upvotes: 0

Views: 5186

Answers (3)

divergent
divergent

Reputation: 291

I don't think you need to set a background image for each page. If you add this snippet to App.xaml :

<ImageBrush x:Key="imgKey" ImageSource="/Images/imgName.png" />

And change the Grid configuration in MainPage.xaml to :

<Grid x:Name="LayoutRoot" Background="{StaticResource imgKey}">

Your image should be displayed on all pages of your app.

Upvotes: 1

coder
coder

Reputation: 13250

Have you tried this way?

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;
    }

Upvotes: 3

Igor Kulman
Igor Kulman

Reputation: 16361

There is no way to set a background image globally. You need to set it for each page.

Upvotes: 0

Related Questions