Skip to main content
All docs
V22.2

CRXPF0010 - Use DependencyObjectExtensions.DataContext to define bindings for generated columns

Severity: Warning

The analyzer detects that you generate columns from a collection and bind column properties (in the ColumnGeneratorTemplate or ColumnGeneratorTemplateSelector) without the DependencyObjectExtensions.DataContext attached property. In this case, the GridControl may work slower.

Examples

Invalid Code

<Window ...
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
    <dxg:GridControl ...
                     ColumnsSource="{Binding Columns}">
        <dxg:GridControl.ColumnGeneratorTemplate>
            <DataTemplate>
                <dxg:GridColumn FieldName="{Binding FieldName}"/>
            </DataTemplate>
        </dxg:GridControl.ColumnGeneratorTemplate>
    </dxg:GridControl>

Valid Code

<Window ...
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
        xmlns:dxci="http://schemas.devexpress.com/winfx/2008/xaml/core/internal">
    <dxg:GridControl ...
                     ColumnsSource="{Binding Columns}">
        <dxg:GridControl.ColumnGeneratorTemplate>
            <DataTemplate>
                <dxg:GridColumn FieldName="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}"/>
            </DataTemplate>
        </dxg:GridControl.ColumnGeneratorTemplate>
    </dxg:GridControl>

How to Fix

Use the DependencyObjectExtensions.DataContext attached property to define bindings in templates used to generate columns.

Refer to the following help topic for more information: Bind the Grid to a Collection of Columns.