Version

Using xamCheckEditor as a Field in xamDataGrid

An important feature of the xamCheckEditor™ control is its ability to be embedded in a xamDataGrid™ Field. This feature allows your end user to take advantage of the editor’s full potential while modifying a cell’s value. The xamCheckEditor control is also more visually appealing than just using the words True and False.

XamDataGrid will automatically use xamCheckEditor as the default editor for boolean type fields. However for fields of other types, follow these steps to display a xamCheckEditor in a Field of xamDataGrid.

  1. Create a Microsoft® Windows® Presentation Foundation Window or Page project.

  1. Place the following namespace declarations inside the opening Page or Window tag. These declarations allow you to reference xamDataGrid, xamCheckEditor, and to define types (i.e. Int32, Boolean).

    In XAML:

    xmlns:igDP="http://infragistics.com/DataPresenter"
    xmlns:igEditors="http://infragistics.com/Editors"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
  1. Create a resource section defining an XmlDataProvider. The XmlDataProvider references the Employees XML file. Place the following XAML inside the Grid Panel.

    In XAML:

    <Grid.Resources>
        <XmlDataProvider Source="../Data/Employees.xml"
            x:Key="EmployeeData" XPath="/employees" />
    </Grid.Resources>
  1. Create an instance of XamDataGrid, name it, and set the DataSource property to the XmlDataProvider created in the previous step.

    In XAML:

    <igDP:XamDataGrid x:Name="XamDataGrid1"
        DataSource="{Binding Source={StaticResource EmployeeData}, XPath=employee}">
            ...
    </igDP:XamDataGrid>
  1. Set the AutoGenerateFields property off the FieldLayoutSettings object to False. Place the following XAML between the tags created in the previous step.

    In XAML:

    ...
    <igDP:XamDataGrid.FieldLayoutSettings>
        <igDP:FieldLayoutSettings AutoGenerateFields="False" />
    </igDP:XamDataGrid.FieldLayoutSettings>
    ...
  1. Set a Label for each Field. If you don’t provide a Label, the Name of the Field is used. Create three Fields. For the first field, set the FieldSettings EditAsType and EditorType properties. The EditAsType property defines a Type for the Field. In this case, you want the Field to display Booleans. The EditorType property sets the Type of ValueEditor to use. In this case, you are using the XamCheckEditor. Place this code below the code in the previous step.

    In XAML:

    ...
    <igDP:XamDataGrid.FieldLayouts>
        <igDP:FieldLayout>
            <igDP:FieldLayout.Fields>
                <igDP:Field Name="active" Label="Active Status" >
                    <igDP:Field.Settings>
                        <igDP:FieldSettings
                            EditAsType="{x:Type sys:Boolean}"
                            EditorType="{x:Type igEditors:XamCheckEditor}" />
                    </igDP:Field.Settings>
                </igDP:Field>
                <igDP:Field Name="name" Label="Employee's Name" />
                <igDP:Field Name="department" Label="Department" />
            </igDP:FieldLayout.Fields>
        </igDP:FieldLayout>
    </igDP:XamDataGrid.FieldLayouts>
    ...
  1. Build and run the project. You should see a xamCheckEditor in the first field of xamDataGrid similar to the image below.

    using xamcheckeditor in xamdatagrid field