Skip to main content
A newer version of this page is available. .
Tag

ColumnBase.Binding Property

Gets or sets the binding that associates the column with a property in the data source.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v19.1.Core.dll

Declaration

[DefaultValue(null)]
public BindingBase Binding { get; set; }

Property Value

Type Default Description
BindingBase *null*

A BindingBase object representing the data binding for the column.

Remarks

The Binding property allows a column to specify a property of the grid control’s DataControlBase.ItemsSource to bind to. Note that the data source should implement INotifyPropertyChanged to notify the grid control that a property value has changed.

The attributes-based validation does not work when using the Binding property.

Columns bound to data using the Binding property are read-only by default. Set the binding’s Mode property to TwoWay to enable editing.

To bind a column to a property using the RelativeSource or Source binding, create a ColumnBase.CellTemplate for this column and define the binding within it.

Tip

When working with data structures that contain Dynamic Objects, use the Binding property instead of ColumnBase.FieldName.

Columns that are bound using the Binding property might work more slowly than columns that use the ColumnBase.FieldName property.

Learn more: Binding Columns to Data Source Fields.

Tip

When the Binding property is specified, the ColumnBase.FieldName property should not contain an existing property name.

Learn more: Binding Columns to Data Source Fields.

Note

Setting the Binding.UpdateSourceTrigger property for the binding passed to the Binding property has no effect. Use the DataViewBase.EnableImmediatePosting to control how the cell values are actually posted.

When a GridColumn is bound using the Binding property, the GridControl automatically initializes its ColumnBase.FieldName property with a value generated based on the specified binding expression to properly recognize columns. If you are using a similar binding expression for your columns, to avoid problems with column recognition, set unique ColumnBase.FieldName values for your columns with Binding (the FieldName property value should not refer to an existing data source property).

Example

<dxg:GridControl x:Name="grid">
            <dxg:GridControl.Columns>
                <dxg:GridColumn Header="Id" FieldName="col1" Binding="{Binding Path=Id, Mode=TwoWay}"/>
                <dxg:GridColumn Header="First Name" FieldName="col2" Binding="{Binding Path=FirstName, Mode=TwoWay}"/>
                <dxg:GridColumn Header="Last Name" FieldName="col3" Binding="{Binding Path=LastName, Mode=TwoWay}"/>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView Name="View"  ShowAutoFilterRow="True" NewItemRowPosition="Top" AllowPerPixelScrolling="True"/>
            </dxg:GridControl.View>
        </dxg:GridControl>

Note

The ColumnBase.FieldName or Binding (that also sets ColumnBase.FieldName internally) properties must be defined for every GridControl column.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Binding property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also