Category / Section
How to conditionally enabled or disable CheckBox in WPF DataGrid (SfDataGrid) Column?
1 min read
The CheckBox check state will be updated based on the content for that specified cell in WPF DataGrid (SfDataGrid). To update check state based on other column value in the same record, IValueConverter can be implemented and the Convert() method can be implemented to have your own condition.
public class ChangeState : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var data = value as OrderInfo;
if ((data.OrderID % 2) == 0) //To add your own condition
return true;
return false;
}
}
To bind the converter for GridCells.
<Window.Resources>
<local:ChangeState x:Key="converter" />
<Style x:Key="cellStyle" TargetType="syncfusion:GridCell">
<Setter Property="IsEnabled" Value="{Binding Converter={StaticResource converter}}" />
</Style>
</Window.Resources>
<syncfusion:GridCheckBoxColumn CellStyle="{StaticResource cellStyle}" MappingName="Status" />
Did not find the solution
Contact Support