wpf-devexpress-dot-xpf-dot-grid-dot-basecolumn-f5f37675.md
Gets or sets the binding that determines a cell’s enabled state.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll
NuGet Package : DevExpress.Wpf.Grid.Core
[DefaultValue(null)]
public BindingBase IsEnabledBinding { get; set; }
<DefaultValue(Nothing)>
Public Property IsEnabledBinding As BindingBase
| Type | Default | Description |
|---|---|---|
| BindingBase | null |
The binding that associates the enabled state of cells with a property in a data source.
|
The code sample below disables cells in the Start Date and Due Date columns if the Progress value equals 100% :
View Example: Read-only and Enabled State Binding
<dxg:TreeListControl x:Name="treeList"
ItemsSource="{Binding Path=EditableDataSource, Source={StaticResource employeeTasks}}">
<dxg:TreeListControl.Columns>
<dxg:TreeListColumn FieldName="Name" Header="Task"/>
<dxg:TreeListColumn FieldName="Employee" Header="Assignee"/>
<dxg:TreeListColumn FieldName="Status" Header="Progress"/>
<dxg:TreeListColumn FieldName="StartDate"
IsEnabledBinding="{Binding IsCompleted, Converter={dx:BoolInverseConverter}}"/>
<dxg:TreeListColumn FieldName="DueDate"
IsEnabledBinding="{Binding IsCompleted, Converter={dx:BoolInverseConverter}}"/>
</dxg:TreeListControl.Columns>
<dxg:TreeListControl.View>
<dxg:TreeListView x:Name="view" KeyFieldName="ID" ParentFieldName="ParentID"/>
</dxg:TreeListControl.View>
</dxg:TreeListControl>
public class EmployeeTask: INotifyPropertyChanged {
public int ID { get; set; }
public int ParentID { get; set; }
public string Name { get; set; }
public string Employee { get; set; }
public DateTime StartDate { get; set; }
public DateTime DueDate { get; set; }
public bool IsCompleted { get { return Status == 100; } }
int _status;
public int Status {
get { return _status; }
set { _status = value; OnPropertyChanged(); OnPropertyChanged("IsCompleted"); }
}
// ...
}
Public Class EmployeeTask Inherits INotifyPropertyChanged
Public Property ID As Integer
Public Property ParentID As Integer
Public Property Name As String
Public Property Employee As String
Public Property StartDate As DateTime
Public Property DueDate As DateTime
Public ReadOnly Property IsCompleted As Boolean
Get
Return Status = 100
End Get
End Property
Private _status As Integer
Public Property Status As Integer
Get
Return _status
End Get
Set(ByVal value As Integer)
_status = value
OnPropertyChanged()
OnPropertyChanged("IsCompleted")
End Set
End Property
' ...
End Class
To change the appearance settings of read-only cells, use the ColumnBase.CellStyle property with a trigger. Use the LightweightCellEditor as the style’s target type.
<dxg:TreeListColumn.CellStyle>
<Style TargetType="dxg:LightweightCellEditor">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="DarkGray" />
</Trigger>
</Style.Triggers>
</Style>
</dxg:TreeListColumn.CellStyle>
Use the LightweightCellEditor.EditorOpacity property to change the opacity of the cell editor displayed in a disabled cell.
For more information, refer to Disable Editing.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the IsEnabledBinding 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.
wpf-grid-read-only-and-enabled-binding/CS/MainWindow.xaml#L36
</dxg:TreeListColumn>
<dxg:TreeListColumn FieldName="StartDate" Width="100" IsEnabledBinding="{Binding IsCompleted, Converter={dx:BoolInverseConverter}}"/>
<dxg:TreeListColumn FieldName="DueDate" Width="100" IsEnabledBinding="{Binding IsCompleted, Converter={dx:BoolInverseConverter}}"/>
See Also