Click here to Skip to main content
15,884,042 members
Articles / Desktop Programming / XAML
Tip/Trick

ColorPicker In Windows Phone 8

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
12 Nov 2014CPOL 9.8K   233   4  
This code sample demonstrates how to set color to any control using colorpicker. For this, you have to create a new Windows phone app.

Introduction

This code sample demonstrates how to set color to any control using colorpicker. For this, you have to create a new Windows phone app.

Step 1: Create a New Windows Phone App

Image 1

Step 2: Add Toolkit

For colorpicker control, you have to install toolkit or add reference to that DLL file. For that, right click on reference and choose add reference option in which choose browse option and browse their DLL file (Coding4Fun.Phone.Controls.dll).

Image 2

After adding this DLL file, it will appear in the reference file.

Image 3

Step 3: Set MainPage UI as Per Below

Add namespace MainPage.xaml page:

XML
xmlns:c4fToolkit="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls"

Write this code in MainPage.xaml:

XML
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
          <StackPanel>
          <c4fToolkit:ColorPicker x:Name="picker" Height="300"
               Width="400" ColorChanged="picker_ColorChanged" />
           <Rectangle  Height="150" Margin="0,30,0,0" Width="150" x:Name="ColorRect"/>
          </StackPanel>
 </Grid>

Step 4: Add colorpicker Change Event and Write this Code in MainPage.xaml.cs Page

Add namespace using System.Windows.Media;; for SolidColorBrush.

It will set rectangle color.

C#
private void picker_ColorChanged(object sender, System.Windows.Media.Color color)
 {
         ColorRect.Fill = new SolidColorBrush(color);
 }

Step 5: Output of this Code

Image 4

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --