Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Windows 8.1 App Change Grid Background
WhatsApp
Ajeya Shetti
Aug 02
2015
1.8
k
0
0
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#
Up Next
Windows 8.1 App Change Grid Background