j.pn
j.pn

Reputation: 61

How to Change Page's Background Color, Windows Phone 8.1 C# XAML

I want to change Page's Background Color from Code Behind. But I don't know how to do this.

Please tell me how to write Code about changing Background Color.

I use Visual Studio 2015 C# XAML enviroment.

Upvotes: 0

Views: 627

Answers (1)

Sunteen Wu
Sunteen Wu

Reputation: 10627

To set the page's background color in code behind, we should get the page object from xaml. So add x:Name property for the page and set the background color from code behind.

XAML Code

    <Page   ...  x:Name="thispage"> 

Code Behind

    SolidColorBrush redbrush=new SolidColorBrush(Colors.Red);//your color        
    thispage.Background = redbrush;  

Upvotes: 3

Related Questions