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
2589
Binding to dynamic data - item validation is not working
posted

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.

Parents
  • 40030
    Verified Answer
    Offline posted

    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

Reply Children
No Data