TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Windows 8.1 App Change Grid Background
Ajeya Shetti
Aug 02
2015
Code
1.7
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
screenshots.zip
MainPage.xaml
<
Page
x:Class
=
"App3.MainPage"
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
=
"http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local
=
"using:App3"
xmlns:d
=
"http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
=
"http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable
=
"d"
Background
=
"{ThemeResource ApplicationPageBackgroundThemeBrush}"
>
<
Grid
Name
=
"MyGrid"
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"6*"
/>
<
ColumnDefinition
Width
=
"19*"
/>
</
Grid.ColumnDefinitions
>
<
Button
Content
=
"Click Me"
HorizontalAlignment
=
"Left"
Margin
=
"25.167,80,0,0"
VerticalAlignment
=
"Top"
Height
=
"74"
Width
=
"142"
FontSize
=
"24"
FontFamily
=
"Global User Interface"
Click
=
"Button_Click"
Grid.Column
=
"1"
/>
<
TextBlock
x:Name
=
"myTextBlock"
HorizontalAlignment
=
"Left"
Margin
=
"25.167,246,0,0"
TextWrapping
=
"Wrap"
VerticalAlignment
=
"Top"
Height
=
"115"
Width
=
"142"
FontSize
=
"22"
Grid.Column
=
"1"
/>
</
Grid
>
</
Page
>
MainPage.xaml.cs
using
System;
using
System.Collections.Generic;
using
System.IO;
using
System.Linq;
using
System.Runtime.InteropServices.WindowsRuntime;
using
Windows.Foundation;
using
Windows.Foundation.Collections;
using
Windows.UI;
using
Windows.UI.Xaml;
using
Windows.UI.Xaml.Controls;
using
Windows.UI.Xaml.Controls.Primitives;
using
Windows.UI.Xaml.Data;
using
Windows.UI.Xaml.Input;
using
Windows.UI.Xaml.Media;
using
Windows.UI.Xaml.Navigation;
namespace
App3 {
public
sealed
partial
class
MainPage: Page {
public
MainPage() {
this
.InitializeComponent();
this
.NavigationCacheMode = NavigationCacheMode.Required;
}
protected
override
void
OnNavigatedTo(NavigationEventArgs e) {}
private
void
Button_Click(
object
sender, RoutedEventArgs e) {
if
(MyGrid.Background ==
null
) {
MyGrid.Background =
new
SolidColorBrush(Colors.Red);
}
else
{
MyGrid.Background =
null
;
}
}
}
}
Windows App
C#