Skip to main content
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.v22.1.Core.dll

NuGet Package: DevExpress.Wpf.Grid.Core

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

Use the Binding property to bind columns to data source properties. The data source should implement INotifyPropertyChanged to notify the grid control that a property value has changed.

Set the binding’s Mode property to TwoWay to enable editing.

Columns with the specified Binding property work as unbound columns and obtain a field type from the first item. You can use the ColumnBase.UnboundType property to specify the field type:

<dxg:GridColumn Binding="{Binding Value , Mode=TwoWay}" UnboundType="Object">

Limitations

The following limitations apply when you use the Binding property:

To use the RelativeSource or Source binding, create a ColumnBase.CellTemplate for this column and define the binding within the template.

Refer to the following topic for more information: Binding Columns to Data Source Fields.

Tip

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

When you use the Binding property, the ColumnBase.FieldName property should not contain an existing property name.

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.

How the GridControl Identifies Columns

The GridControl identifies columns by their ColumnBase.FieldName values. When you use the Binding property to bind a column to a data field, the GridControl initializes the ColumnBase.FieldName property with a value based on the specified binding expression. If you have multiple columns with the same binding path, set their FieldName to unique values to enable the GridControl to distinguish between columns:

<dxg:GridColumn Binding="{Binding Id, Converter={StaticResource converter1}}" FieldName="c1"/>
<dxg:GridColumn Binding="{Binding Id, Converter={StaticResource converter2}}" FieldName="c2"/>

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"/>
    </dxg:GridControl.View>
</dxg:GridControl>
See Also