Universal Windows Platform – Colour Picker

Colour Picker shows how to create an application which will show how to use the ColorPicker Control

Step 1

If not already, follow Setup and Start on how to Install and get Started with Visual Studio 2017 or in Windows 10 choose Start, and then from the Start Menu find and select Visual Studio 2017.


Step 2

Once Visual Studio Community 2017 has started, from the Menu choose File, then New then Project…


Step 3

From New Project choose Visual C# from Installed, Templates then choose Blank App (Universal Windows) and then type in a Name and select a Location and then select Ok to create the Project

Step 4

Then in New Universal Windows Project you need to select the Target Version this should be at least the Windows 10, version 1803 (10.0; Build 17134) which is the April 2018 Update and the Minimum Version to be the same.


The Target Version will control what features your application can use in Windows 10 so by picking the most recent version you’ll be able to take advantage of those features. To make sure you always have the most recent version, in Visual Studio 2017 select Tools Extensions and Updates… then and then see if there are any Updates

Step 5

Then in the Solution Explorer select MainPage.xaml


Step 6

From the Menu choose View and then Designer


Step 7

The Design View will be displayed along with the XAML View and in in this between the Grid and /Grid elements, enter the following XAML:

<Grid Margin="50">
		<ColumnDefinition Width="Auto"/>
		<ColumnDefinition Width="*"/>
	<ColorPicker Grid.Column="0" Name="Picker" IsColorSliderVisible="True" IsColorChannelTextInputVisible="True"
	IsHexInputVisible="True" IsAlphaEnabled="False" IsAlphaSliderVisible="True" 
	IsAlphaTextInputVisible="True" ColorChanged="Picker_ColorChanged"/>
	<Rectangle Grid.Column="1" Name="Display" Margin="25"/>

Within the main Grid Element, is a block of XAML containing another Grid Control with two Columns – the first Column is the ColorPicker Control with various Properties set and the second Column is a Rectangle Control.

Step 8

From the Menu choose View and then Code


Step 9

Once in the Code View, below the end of public MainPage() { … } the following Code should be entered:

private void Picker_ColorChanged(ColorPicker sender, ColorChangedEventArgs args)
	Display.Fill = new SolidColorBrush(Picker.Color);

There is an Picker_ColorChanged Event Handler which within sets the Fill Property of the Rectangle to a SolidColorBrush based on the Color selected from the ColorPicker.

Step 10

That completes the Universal Windows Platform Application so Save the Project then in Visual Studio select the Local Machine to run the Application


Step 11

Once the Application has started running you can select a Colour from the ColorPicker and this will be displayed as the Colour of the Rectangle


Step 12

To Exit the Application select the Close button in the top right of the Application


Colour Picker is a simple application that shows how easy it is to use the ColorPicker Control in an Application.

Creative Commons License

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s