Version

Using xamTextEditor as a Field in xamDataGrid

An important feature of the xamTextEditor™ 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.

Follow these steps to display xamTextEditor 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, xamTextEditor, 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/Orders.xml"
            x:Key="OrderData" XPath="/Orders" />
    </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 OrderData}, XPath=Order}">
        ...
    </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. The following XAML creates the Fields and sets the FieldSettings EditAsType and EditorType properties for the first Field. Set the EditAsType property to String. The EditorType property defines what Type of ValueEditor to use. In this case, you are using the XamTextEditor. Place this code below the code in the previous step.

    In XAML:

    ...
    <igDP:XamDataGrid.FieldLayouts>
        <igDP:FieldLayout>
            <igDP:FieldLayout.Fields>
                <igDP:Field Name="ProductName" >
                    <igDP:Field.Settings>
                        <igDP:FieldSettings
                            EditAsType="{x:Type sys:String}"
                            EditorType="{x:Type igEditors:XamTextEditor}" />
                    </igDP:Field.Settings>
                </igDP:Field>
                <igDP:Field Name="CostPerUnit" />
                <igDP:Field Name="ShipAndHandle" />
            </igDP:FieldLayout.Fields>
        </igDP:FieldLayout>
    </igDP:XamDataGrid.FieldLayouts>
    ...
  1. Build and run the project. You won’t notice a difference when using xamTextEditor in a Field. However, if you retrieve the cell’s value, you will notice a difference. If you were to place numeric data in xamTextEditor, the editor would return the number as a string. If you placed numeric data in a numeric editor, the editor would return the value in the type it is set to (i.e., Int32, Double).

    using xamtexteditor in a xamdatagrid's field