locked
DataGrid clear validation errors RRS feed

  • Question

  • Hi!
    I'm having some trouble with my DataGrid. It's editable and connected to an observable collection with a rowvalidationrul. I need to be able to remove a row whether a row is valid or not.

    The problem I'm facing is that when the grid gets a validation error it becomes read only and stays that way even after the invalid row is removed. Does anyone have a working solution for this?

    P.S. Is it ok now to post DataGrid questions here? I posted on CodePlex but doesn't seem to be too many people there.

    Monday, April 12, 2010 11:48 AM

Answers

  • YIIIPIIIIIII!!!

    I found a solution to my problems. I simply set DataGrid.Itemssource = null, and then I set it again to my observable collection.
    The grid seems to reset, clearing the validation.

    It's not pretty but it's short, simple and it works.

    Monday, April 12, 2010 12:50 PM

All replies

  • If you just put a delete button in the row, does it know to disable it?

    or

    How about delete the row out the underlying bound collection?

    Via a contextmenu perhaps.

    Although in this case you want to look at the code I posted yesterday as there's a gotcha inherent to contextmenu.

    or

    Tell your users to press escape.

    Monday, April 12, 2010 12:13 PM
  • I have a button to delete the row and I remove the row from the collection. That part is no problem. The problem is that the validation error still persists making keeping the rest of the grid in an uneditable mode.

    I read som more here: http://wpf.codeplex.com/Thread/View.aspx?ThreadId=46457&ANCHOR

    Does anyone have an example of a solution?

    Monday, April 12, 2010 12:29 PM
  • YIIIPIIIIIII!!!

    I found a solution to my problems. I simply set DataGrid.Itemssource = null, and then I set it again to my observable collection.
    The grid seems to reset, clearing the validation.

    It's not pretty but it's short, simple and it works.

    Monday, April 12, 2010 12:50 PM
  • Oh my goodness, that IS not pretty.  Has anybody come up with a better solution?
    Saturday, January 12, 2013 12:50 AM
  • it is not working
    Thursday, December 20, 2018 6:45 AM