Infragistics(R) NetAdvantage(R) : WPF 2012.1
Create a Custom Palette
E-mail your feedback on this topic.
Shared XAML > Editors > xamColorPicker > Using xamColorPicker > Create a Custom Palette

Glossary Item Box

There maybe be certain situations where the pre-defined palette does not suit your needs and you would like to expand the available palettes.

You can easily add your own custom palette to the xamColorPicker control by adding it to the ColorPalettes collection.

The following code demonstrates how to achieve this.

In XAML:

<ig:XamColorPicker x:Name="MyColorPicker" DerivedPalettesCount="10" Width="100"   
                   Height="30" >
   <ig:XamColorPicker.ColorPalettes>
      <!-- Create Custom Palette -->
      <ig:ColorPalette>
         <ig:ColorPalette.Colors>
            <ig:ColorPatchCollection>
               <ig:ColorPatch Color="Red"/>
               <ig:ColorPatch Color="Orange"/>
               <ig:ColorPatch Color="Yellow"/>
               <ig:ColorPatch Color="Green"/>
               <ig:ColorPatch Color="Blue"/>
               <ig:ColorPatch Color="Indigo"/>
               <ig:ColorPatch Color="Violet"/>
               <ig:ColorPatch Color="Red"/>
               <ig:ColorPatch Color="Orange"/>
               <ig:ColorPatch Color="Yellow"/>
            </ig:ColorPatchCollection>
         </ig:ColorPalette.Colors>
      </ig:ColorPalette>
   </ig:XamColorPicker.ColorPalettes>
</ig:XamColorPicker>

In Visual Basic:

Dim MyColorPalette As New ColorPalette()
MyColorPalette.Colors.Add(Colors.Red)
MyColorPalette.Colors.Add(Colors.Orange)
MyColorPalette.Colors.Add(Colors.Yellow)
MyColorPalette.Colors.Add(Colors.Green)
MyColorPalette.Colors.Add(Colors.Blue)
MyColorPalette.Colors.Add(Colors.Purple) 
MyColorPalette.Colors.Add(Colors.Magenta)
MyColorPalette.Colors.Add(Colors.Red)
MyColorPalette.Colors.Add(Colors.Orange)
MyColorPalette.Colors.Add(Colors.Yellow)

MyColorPicker.ColorPalettes.Add(MyColorPalette)

In C#:

ColorPalette MyColorPalette = new ColorPalette();
MyColorPalette.Colors.Add(Colors.Red);
MyColorPalette.Colors.Add(Colors.Orange);
MyColorPalette.Colors.Add(Colors.Yellow);
MyColorPalette.Colors.Add(Colors.Green);
MyColorPalette.Colors.Add(Colors.Blue);
MyColorPalette.Colors.Add(Colors.Purple);
MyColorPalette.Colors.Add(Colors.Magenta);
MyColorPalette.Colors.Add(Colors.Red);
MyColorPalette.Colors.Add(Colors.Orange);
MyColorPalette.Colors.Add(Colors.Yellow);
            
this.MyColorPicker.ColorPalettes.Add(MyColorPalette);

The following screenshot displays the xamColorPicker control with two custom palettes added.

 

Related Topics

Advanced Editor

Palettes

Selected Color