Silverlight Color Selector Control
This Color Selector control provides the user with a simple way to select from a list of pre-defined colors.
This Silverlight only Color Selector Control is easy to implement on your Silverlight driven website and is also customizable to provide a visual feel suitable for any site design.
If you want use Color Selector Control you will need to add a reference to Liquid.dll in your application.
Download a Liquid_5_1_7.dll.zip from top of the article.
Creating a ColorSelector Control
The ColorSelector element represents a ColorSelector control in XAML.
<liquid:ColorSelector />
The Background property represents a Background color of the ColorSelector. The BorderBrushPropoerty represents a Border of the ColorSelector, X:Name property represents a name of the ColorSelector.
The code snippet creates a ColorSelector control and sets the Background, BorderBrush and X:Name Property.
<liquid:ColorSelector Background="Black" BorderBrush="Blue" x:Name="selectColor"SelectionChanged=
"selectColor_SelectionChanged" />
SilverlightColorSelector.xaml
<UserControl x:Class="SilverlightColorSelector.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:liquid="clr-namespace:Liquid;assembly=Liquid"
Width="400" Height="300">
<Grid x:Name="LayoutRoot">
<liquid:ColorSelector Background="Blue" BorderBrush="Green" x:Name="selectColor"SelectionChanged="
selectColor_SelectionChanged" />
</Grid>
</UserControl>
SilverlightColorSelector.xaml.vb
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Namespace SilverlightColorSelector
Partial Public Class Page
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
Private Sub selectColor_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
LayoutRoot.Background = New SolidColorBrush(selectColor.Selected)
End Sub
End Class
End Namespace
The output is :

Figure 1
If you select any color like Red the Result is :

Figure 2
Summary
In this article, I discussed how we can use a silverlight color selector control.