This project has moved and is read-only. For the latest updates, please go here.


Crash adding a new record from DataGrid


BookApplication, press Add to add a new book, click on Title to start editing cell, then lose focus clicking on another control (for example, "Address Book" tab) and there is an exception from line

_Title = StructuralObject.SetValidValue(value, false);

because it tries to set a null value to the Title.

How can this be avoided?


jbe2277 wrote Mar 23, 2013 at 12:00 PM

Thank you for your feedback.

I’m able to see this exception in the Debugger but the BookLibrary application doesn’t crash. The exception is catched by the WPF Binding infrastructure. Therefore, this shouldn’t be an issue.

The exception comes because the Title column in the database is set to Nullable = false. When the WPF Binding tries to write “null” into the property setter then this exception is thrown. You might initialize the Title and Author properties with “string.Empty” in the constructor of the Book class.

This exception does not occur anymore in the new WAF BookLibrary sample application because now it uses the POCO approach.

gusi wrote Mar 23, 2013 at 12:26 PM

Hi! And thanks for checking this.
You're right, I had the debugger set to halt on exceptions, but without the debugger the exception is correctly handled. Sorry for not seeing this first! :(

wrote Jun 18, 2013 at 10:13 AM

wrote Aug 25, 2013 at 2:10 PM