CanUserAddRows binding error in themedDataGrid

Editors for WPF Forum

Posted 10 years ago by Sasha
Version: 14.1.0602


we deal with a strange behavior of a property CanUserAddRows during binding. Our goal is following behavior - when a cell value is 0, set CanUserAddRows to false, if any other value - to true. Here is xaml code :

<datagrid:ThemedDataGrid Grid.Row="2" Grid.Column="2" 
		 CanUserAddRows="{Binding CanAddRows}"
		 IsReadOnly="{Binding IsDatagridReadOnly}"
		 SelectedIndex="{Binding ModulBasisSelectedIndex}"
		 SelectedValue="{Binding ModulBasisSelectedValue}"
		 ItemsSource="{Binding ModulBasisCollection}" 
		 SelectionUnit="FullRow" GridLinesVisibility="All" 
		 CellStyle="{StaticResource DataGridCellStyleKey}" 
		    <i:EventTrigger EventName="CellEditEnding">
			<ei:CallMethodAction TargetObject="{Binding}" MethodName="OnModulBasisCellEditEnding"/>
			<datagrideditors:DataGridInt32Column Binding="{Binding BASIS, UpdateSourceTrigger=PropertyChanged}"

 Here is property :

public bool CanAddRows
    get { return _canAddRows; }
        if(value == _canAddRows) return;
        _canAddRows = value;

 And we are changing this property on OnModulBasisCellEditEnding event :

 public void OnModulBasisCellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
     if (e.EditAction != DataGridEditAction.Commit) return;

     var item = e.Row.Item as MODUL_BASIS;
     if (null == item) return;          

     if (0 == item.BASIS)
         CanAddRows = false;               
         CanAddRows = true;

 When themedDatagrid is loaded, value is false by default. Then we add an item with value 1 and user is able to add new rows. If to enter value greater than 0, everything works fine. When 0 is entered, dataGrid changes value of canUserAddRows to false and user are not able to add rows. After that, value of themedDataGrid is always false and never changing back to true, no matter what value was entered.

How can I set it back to true?

Thank you

Comments (3)

Answer - Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Sasha,

For things like this that require some debugging, we really need a small sample project to debug.  Can you please put your sample together in a new simple sample project and email it to our support address?  Please rename the .zip file extension so it doesn't get spam blocked, and reference this thread.  Thanks!

Actipro Software Support

Posted 8 years ago by John Smith

I have the same problem. I want to bind SelectionMode-Property of ThemedDataGrid to my property in ViewModel and it don't work.

My dataGrid:

                            <datagrid:ThemedDataGrid AutoGenerateColumns="False" CanUserAddRows="False" 
								 CanUserDeleteRows="False" ItemsSource="{Binding MessStellenColection}"  
                                 CellStyle="{StaticResource DataGridCellStyleKey}" Margin="3" 
                                 SelectionMode="{Binding GrafikSelectionMode}" CanUserSortColumns="False" CanUserReorderColumns="False">

 my Property in ViewModel:

        public SelectionMode GrafikSelectionMode
            get { return _selectionMode; }
                _selectionMode = value;

 The SelectionMode is always "Extended".



Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA


The SelectionMode property is part of Microsoft's DataGrid control and appears to be a normal dependency property.  We don't alter or modify it in any way in our ThemedDataGrid control, which directly inherits the Microsoft DataGrid.  Perhaps you have a binding error?  Or if you are sure the binding is correct, you might want to follow up in Microsoft's support forums on this since it likely still happens if you swap to the normal native WPF DataGrid control.

Actipro Software Support

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.