Infragistics(R) NetAdvantage(R) : WPF 2012.1
Adding xamColorPicker to Your Grid
E-mail your feedback on this topic.
Shared XAML > Editors > xamColorPicker > Using xamColorPicker > Adding xamColorPicker to Your Grid

Glossary Item Box

Before You Begin

The xamColorPicker™ control is a simple editor control that allows your end users to select a color value from a pre-defined palette of colors.

What You Will Accomplish

This topic will demonstrate how to add a xamColorPicker control to your DataGrid control using XAML.

Follow These Steps

  1. Create a WPF project.
  2. In the Solution Explorer, add the following references to your project:
    1. InfragisticsWPF4.v12.1.dll
    2. InfragisticsWPF4.Controls.Editors.XamColorPicker.v12.1.dll
    3. InfragisticsWPF4.Controls.Editors.XamSlider.v12.1.dll
  3. Add the following namespace declarations for xamColorPicker and Windows.Controls:

    In XAML:

    xmlns:ig="http://schemas.infragistics.com/xaml"
    xmlns:msd="clr-namespace:System.Windows.Controls;
        assembly=System.Windows.Controls.Data"
    
    
  4. Add a DataGrid Control to your page. Set the following:
    1. x:Name - MyDataGrid
    2. In the Columns collection add a template column
    3. In the DataTemplate add a xamColorPicker control with Width - 40

      In XAML:

      <msd:DataGrid x:Name="MyDataGrid" AutoGenerateColumns="False">
        <msd:DataGrid.Columns>
          <msd:DataGridTemplateColumn CanUserSort="False">
            <msd:DataGridTemplateColumn.CellTemplate>
              <DataTemplate>
                <ig:XamColorPicker x:Name="MyColorPicker"
                                   DerivedPalettesCount="10"
                                   Width="40" />
              </DataTemplate>
            </msd:DataGridTemplateColumn.CellTemplate>
          </msd:DataGridTemplateColumn>
        </msd:DataGrid.Columns>
      </msd:DataGrid>
      
  5. You can bind the property SelectedColor to the appropriate path of your DataGrid's data source.