We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Data binding


I just want to bind the AllowEditing of the SfDataGrid to the Mapping value "CheckIn". The below AllowEditing binding is not working. Does anyone know how to do it.

 <my:SfDataPager x:Name="sfDataPager" PageSize="3" Source="{Binding List}"/>

<syncfusion:SfDataGrid x:Name="datagrid" ItemsSource="{Binding PagedSource,ElementName=sfDataPager}" >
                <syncfusion:GridCheckBoxColumn AllowEditing="{Binding DataContext.CheckIn}"  MappingName="CheckIn" />             


3 Replies

JG Jai Ganesh S Syncfusion Team October 13, 2016 01:27 PM UTC

Hi Benia, 
We have analyzed your query. We regret to inform you that you can not bind GridCheckBoxColumn’s AllowEditing based on the underlying property but you can disable the cell based on the underlying property like below, 
<syncfusion:GridCheckBoxColumn MappingName="IsChecked" > 
                        <Style TargetType="syncfusion:GridCell"> 
                            <Setter Property="utils:SetterValueBindingHelper.PropertyBinding"> 
                                     <utils:SetterValueBindingHelper Property="IsEnabled"  Binding="{Binding Converter={StaticResource converter}}"/> 
public class customconverter : IValueConverter 
        public object Convert(object value, Type targetType, object parameter, string language) 
           return (value as UserInfo).IsChecked; 
        public object ConvertBack(object value, Type targetType, object parameter, string language) 
            return (value as UserInfo).IsChecked; 
Screen Shot: 
Jai Ganesh S 

MA Muhammed Ali Sheikh February 16, 2022 05:04 PM UTC

Hi Jai Ganesh,

I want the same solution in UWP sfdatagrid. Based on some condition I have to disable some items and let few items enabled. Even though in ObservableCollection I'm disabling few of them but the NotifyPropertyChanged isn't firing. Only upon scrolling the collection is getting updated in the grid.

VS Vijayarasan Sivanandham Syncfusion Team February 17, 2022 11:17 AM UTC

Hi Muhammed Ali Sheikh,

Your requirement can be achieved by using CellStyleSelector property and CurrentCellEndEdit event in SfDataGrid. Please refer the below code snippet, 
XAML Code Snippet: 
        <local:SelectorClass x:Key="styleSelector"/> 
        <Style x:Key="disableCell" TargetType="syncfusion:GridCell"> 
            <Setter Property="IsEnabled" Value="True" /> 
        <Style x:Key="enableCell" TargetType="syncfusion:GridCell"> 
            <Setter Property="IsEnabled" Value="False" /> 
<syncfusion:SfDataGrid x:Name="sfGrid" 
                                   CellStyleSelector="{StaticResource styleSelector}" 
                                   ItemsSource="{Binding UserDetails}" 
C# Code Snippet for update the CellStyle at runtime: 
this.sfGrid.CurrentCellEndEdit += OnCurrentCellEndEdit; 
private void OnCurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs e) 
            //Change the CellStyle at runtime by update the value changed row index in SfDataGrid 
C# Code Snippet for Style Selector: 
public class SelectorClass : StyleSelector 
        protected override Style SelectStyleCore(object item, DependencyObject container) 
            var data = item as UserInfo; 
            //here customize based on your scenario 
            if (data != null && ((container as GridCell).ColumnBase.GridColumn.MappingName == "IsChecked")) 
                //custom condition is checked based on data. 
                if (data.UserId > 10005) 
                    return App.Current.Resources["disableCell"] as Style; 
                return App.Current.Resources["enableCell"] as Style; 
            return base.SelectStyleCore(item, container); 
Sample Link: https://www.syncfusion.com/downloads/support/forum/126380/ze/SfDataGridDemo1204985064

For more information related to Conditional styling of cells using style selector, please refer the below user guide documentation link, 

Vijayarasan S 

Live Chat Icon For mobile
Up arrow icon