We’re using RIA Services / Silverlight 4, and I’m binding a datagrid to something like Context.Foo.
I can see validation errors appearing in the datagrid’s validation summary when users try to enter empty strings into mandatory fields and so forth, life is good.
However when I add a new item by calling something like Context.Foo.Add(new Foo) in the viewModel, the new row appears in the datagrid, but is never validated unless the user clicks on a cell.
Is there a way to ask the DataGrid is validate all items?
Rather than asking the DataGrid to validate the row for you, you will need to validate the object itself that the new row is bound to. You can use the Validator class to do this for you. For example, say your object is assigned to a variable named newRowObject, you can do the following:
This should achieve what you are after (I emphasis should, simply because I didn’t check it myself in an example before I wrote this).
Hope this helps…
Chris