Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
430
XamGrid: internal binding error?
posted

Hello again,

In my application, I need to validate the row before it's added to the grid and cancel the operation if the row is erroneous. I'm using a simple method:

xamGrid.RowExitingEditMode += (s, e) =>
{
	var data = e.Row.Data as AddressBookRecord;
	if (!e.EditingCanceled && !data.IsOkay())
		e.Cancel = true;
};

However, sometimes this handler runs before the setter of the field is invoked, thus making the data invalid.

When I try to debug, I see the following line in the output:

System.Windows.Data Error: 40 : BindingExpression path error:
'RowData' property not found on 'object' ''AddressBookRecord' (HashCode=18474007)'.
BindingExpression:Path=RowData; DataItem='AddressBookRecord' (HashCode=18474007);
target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

I have attached the project where the issue occurs. The steps to reproduce the error are:

1. Click the "Add Contact" button.
2. Type a random name, press tab, type a random email, press Enter and see the row created.
3. The Output window of Visual Studio will show both setters fire and data being valid.
4. Repeat the first two steps once again and see the error and the second setter not firing.

GridTest3.zip
Parents
  • 28407
    posted

    HI Antonk,

     I was not able to track yourerror down.

     I created a more simpler version of your program.

     I have a button that shows the AddNewRow and I bind the XamGrid to a ListCollectionView and once the row is added the AddNewRow disappears.
     
     Please review my sample..Sincerely,
     Matt
     Developer Support Engineer

     

    WpfApplication14.zip
Reply Children