locked
validation alow to save record RRS feed

  • Question

  • Hi All.

    Detail form has some validated fields but when I click SAVE button record are saving in database. How prevent to save record if field is validated?

    Thanks.

    Monday, September 13, 2010 2:26 PM

Answers

  • Hi eugzl,

    Though you can do this but I would recommend that you enable the button only when all the fields are valid. You can bind the button with some RelayCommand in ViewModel. In the CanExecute() method of the view model, you can check if all properties are valid and return true.

    If you still want to do the way you had originally thought, this is discussed here:

    http://stackoverflow.com/questions/127477/detecting-wpf-validation-errors

    Muhammad
    shujaatsiddiqi.blogspot.com

    • Proposed as answer by Min Zhu Wednesday, September 15, 2010 3:41 AM
    • Marked as answer by Min Zhu Monday, September 20, 2010 1:39 AM
    Monday, September 13, 2010 2:46 PM

All replies

  • You can create some property (in Binding with your controls in View) in your VM and when the Command is fired, is up to you if call a Save function or not
    Monday, September 13, 2010 2:35 PM
  • Hi eugzl,

    Though you can do this but I would recommend that you enable the button only when all the fields are valid. You can bind the button with some RelayCommand in ViewModel. In the CanExecute() method of the view model, you can check if all properties are valid and return true.

    If you still want to do the way you had originally thought, this is discussed here:

    http://stackoverflow.com/questions/127477/detecting-wpf-validation-errors

    Muhammad
    shujaatsiddiqi.blogspot.com

    • Proposed as answer by Min Zhu Wednesday, September 15, 2010 3:41 AM
    • Marked as answer by Min Zhu Monday, September 20, 2010 1:39 AM
    Monday, September 13, 2010 2:46 PM
  • Hi Eugzl,

    I am marking this issue as "Answered". If you have any new findings or concerns about this issue, please feel free to let me know.

    Thank you and have a nice day!

    Best regards,

    Min


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Monday, September 20, 2010 1:40 AM