Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the background color of xaml page in wp7 application?

I am developing window phone 7 application. I am new to the window phone 7 application. I want to change the background color of the entire xaml page in the window phone 7 application. I have tried the following code in the constructor of the xaml page

 this.Background = new SolidColorBrush(Colors.White);

But it is not working.

I have also added the attribute in the phone:PhoneApplicationPage tag as follows

<phone:PhoneApplicationPage 
Background="Red"

But it is also not working. Can you please provide me any code or link or any solution through which I can resolve the above issue? If I am doing anything wrong then please guide me.

like image 845
Shailesh Jaiswal Avatar asked Feb 07 '11 11:02

Shailesh Jaiswal


People also ask

How to Change the Background color in wpf?

Navigate to the Properties window, and click the Background drop-down arrow, and choose Red or another color in the color picker.

How can I change my Backcolor?

Select Start > Settings > Personalization > Colors, and then choose your own color, or let Windows pull an accent color from your background.


2 Answers

You can set the Background property of the outermost control on the page. For a default page created in WP7 that would be a Grid named Layout.

You need to change the background of the LayoutRoot if you want to see the effect:

<Grid x:Name="LayoutRoot" Background="YellowGreen">
..
like image 188
Boryana Miloshevska Avatar answered Sep 28 '22 05:09

Boryana Miloshevska


Maybe the theme does not respect the background color in the page. What you can do is add A border as a child of the page and set its background color to whatever you want.

<phone:PhoneApplicationPage> 
<Border Background="Red">
...more content here...
</Border>
</phone:PhoneApplicationPage> 
like image 38
NVM Avatar answered Sep 28 '22 05:09

NVM