Hello
I build a class with Reflection and then bind grid to ObservableCollection<object>. Dynamically created class inherits INotifyPropertyChanged and has all methods I need. This works fine when I only need to display data.
When I set AutoGenerateColumns to true and remove Columns, grid cells display something like Mynamespace.Myclass etc. And in this case I can see notification tooltip when I delete data from cell. But when I create template columns and set AutoGenerateColumns to false, validation won't work.
Solution attached. You only need to uncomment columns in XAML to see the error.
BTW, looks like validation won't work even with "usual" cell data if they bind to a complex object.
Here should be some text which I have removed :)
Everything works ok for now, I just forgot about some binding attributes in XAML, such as NotifyOnValidationError and so on. And I put validation routine in KeyValue class so this looks like working fine now :)
Thank you very much.
Hi,
I took a look at your sample.
Your first case where you're using AutoGeneration, we don't support generating columns for sub properties on an object. For that you must use manual column definitions. Now, when you try to edit a cell in those auto generated columns, you're getting an editing validation error, b/c you're trying to edit an object of type KeyValue, and since the an empty string, or any string for that matter can't be converted to a KeyValue object, it throws the validation exception.
Now, for your second issue. Everything is working as expected. Your KeyValue object doesn't have any validation, thus, no validation exception. I'm not really sure what you're expecting. If you want to have validation on your sub properties, then implement some validation in the setter of your properties. If you throw an exception, the grid will catch it and show it as a validation error.
-SteveZ