Extended Library for WPF and Silverlight | ComponentOne
ColorPicker / C1ColorPicker Task-Based Help / Setting the Palette
In This Topic
    Setting the Palette
    In This Topic

    ColorPicker for WPF and Silverlight includes over 20 predefined color palettes that match the themes used in Microsoft Office. For more information about palette choices, see Available ColorPicker Palettes. To change the color palette, you can set the C1ColorPicker.Palette property.

    To set the C1ColorPicker.Palette property, complete the following steps:

    1. Navigate to the Toolbox and double-click the Button icon to add the control to the project.
    2. Resize and reposition the Button on the form.
    3. Navigate to the Properties window and set the button’s Content property to "Change Palette".
    4. Double-click the button to switch to Code view and create the Button_Click event handler.
    5. Add code for the Button_Click event handler, so it appears like the following:
    Visual Basic
    Copy Code
    Private Sub Button1_Click(ByVal sender as Object, ByVal e as System.Windows.RoutedEventArgs)
        ' Set the color palette.
        Me.C1ColorPicker.Palette = ColorPalette.GetColorPalette(Office2007ColorTheme.GrayScale)
    End Sub
    
    C#
    Copy Code
    private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        // Change color palette.
        this.c1ColorPicker.Palette = ColorPalette.GetColorPalette(Office2007ColorTheme.GrayScale);
    }
    

     

    1. The C1ColorPicker's color palette will now change to grayscale when the button is clicked.

    Run the application and observe the following:

    1. Click the C1ColorPicker control's drop-down arrow and notice that the default palette appears.
    2. Click the Change Palette button and click the C1ColorPicker control's drop-down arrow once again. Notice that a grayscale palette appears: