Step 3 : The BlankPage.xaml file is as in the following code:
Code :
<Page
x:Class="Application4.BlankPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Application4"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="0.010*"/>
<RowDefinition Height="0.081*"/>
<RowDefinition Height="0.058*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.050*"/>
<ColumnDefinition Width="0.333*"/>
</Grid.ColumnDefinitions>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="BlueViolet" Offset="1"/>
<GradientStop Color="Chocolate"/>
</LinearGradientBrush>
</Grid.Background>
<StackPanel Grid.Row="1" Grid.Column="0">
<Button x:Name="RedB" Background="Red" Height="50" Width="50" Click="RedB_Click_1">
</Button>
<Button x:Name="GreenB" Background="Green" Height="50" Width="50" Click="GreenB_Click_1">
</Button>
<Button x:Name="YelloB" Background="Yellow" Height="50" Width="50" Click="YelloB_Click_1">
</Button>
<Button x:Name="BlueB" Background="Blue" Height="50" Width="50" Click="BlueB_Click_1">
</Button>
</StackPanel>
<Grid Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left">
<Frame x:Name="Frame1" Height="400" Width="400" Background="White"></Frame>
</Grid>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Color Box" FontSize="20" Foreground="White">
</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Text="Color Picker Editor" FontSize="20" Foreground="White">
</TextBlock>
</Grid>
</Page>
Step 4 : The BlankPage.xaml.cs file is as in the following code:
Code :
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
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 Application4
{
public sealed partial class BlankPage : Page
{
public BlankPage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void RedB_Click_1(object sender, RoutedEventArgs e)
{
Frame1.Background = new SolidColorBrush(Windows.UI.Colors.Red);
}
private void GreenB_Click_1(object sender, RoutedEventArgs e)
{
Frame1.Background = new SolidColorBrush(Windows.UI.Colors.Green);
}
private void YelloB_Click_1(object sender, RoutedEventArgs e)
{
Frame1.Background = new SolidColorBrush(Windows.UI.Colors.Yellow);
}
private void BlueB_Click_1(object sender, RoutedEventArgs e)
{
Frame1.Background = new SolidColorBrush(Windows.UI.Colors.Blue);
}
}
}
Code 5 : After running this code the output looks like this:
Click the Red color in the Color Box.
Click the Blue color in the Color Box.