How to set background image in windows phone 7 application

Apply background image in windows phone 7 application

In this post I am going show how we can apply an image in your app background. This we can do in XAML and also using C# code.

Video :-

Image :-
Apply background image in you window phone 7 app
XAML code:-

If we want to set image using XAML, it is easy. Just we need to set background for top parent element, in my Demo Grid (default) is top parent element. So, I am applying background image to that.

Just add the below code after <Grid> tag

<ImageBrush ImageSource=”images/bg.png” Stretch=”UniformToFill” />
</Grid.Background> Code:-

Some time we need to change the background using your code. For example if the user selected one movie we need set that film image we need to show in background.

In my example I am use PhotoChooserTask user to select his image for background.

For this we need to do flowing things

*Note: – Please not apply background for grid

// create the PhotoChooserTask object with page scope.

PhotoChooserTask photoChooserTask;


Then in Constructor just add the below highlighted code

InitializeComponent(); photoChooserTask = new PhotoChooserTask();

photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);

In button click event I am just showing PhotoChooserTask

private void imageBrowseBtn_Click(object sender, RoutedEventArgs e)

In photoChooserTask_Completed event

void photoChooserTask_Completed(object sender, PhotoResult e)
if (e.TaskResult == TaskResult.OK)
System.Windows.Media.Imaging.BitmapImage bmp =new System.Windows.Media.Imaging.BitmapImage();
var app = Application.Current as App;
if (app == null)
var imageBrush = new ImageBrush {
ImageSource= bmp,Opacity=0.5d
app.RootFrame.Background = imageBrush;
//app.RootFrame.Background = new SolidColorBrush(Colors.Blue);  — we can apply just color too like this

I hope, it will be helpful for beginners!!!!!

Enjoy while coding..!


Naga Harish.

  • Marcin Sulecki

    Can I change a similary wallpaper in Windows Phone 7 ?

    • Naga Harish Movva

      Hi Marcin,

      I am sorry, because I am not clear with you question first. Can you please tell me in detail. So, may be I can help you..! :) Anyway thanks for visiting my blog :)

      • Marcin Sulecki

        I would like to change system wallpaper Windows Phone 7 in c# code.

        • Naga Harish Movva

          Oh!, you want to change home screen background of your WP7? I hope with this SDK we can’t do that!

  • Pingback: Successfully one year completed for my domain with almost 30K views « Share Our Ideas()

  • Kishor

    Hi I need to set a wallpaper in my windows phone… It should appear behind the tiles. Can you guide me how to do it?

    • Naga Harish Movva

      If I understand you comment correct. It is not possible to set bg for homescreen (Bg behuind tiles).

      • utkarsh

        Are U sure about this thing..i mean is there no app tht can do this thing ??

        • Rish Movva

          Yes @utkarsh, up to my knowledge there is no app or setting to change home screen background (only black or white).
          We can change lock screen image.. there are some many app for that.. for example Facebook and Twitter..