1

I have set up my own ValidationRule so when some validation fails inside a Datagrid, an error appears and you need to correct that error to continue to edit the rest of the grid.

Perfect.

However, you can still "Save" with this error still present. Is there a way I can disable a button if validation fails?

My button is an Command, so therefore I could set "CanExecute" to be false. However this is in my ViewModel so I dont know how to do this.

I can paste my code, but theres a lot of classes plus xaml here which will flood the question, if you have an idea how to do this, I will obviously paste code which is relevant.

Many Thanks Thanks!

user3428422
  • 4,300
  • 12
  • 55
  • 119
  • Exact duplicate of [WPF command binding with input validation - how to enable the "save" button only if all input is valid](http://stackoverflow.com/questions/23110880/wpf-command-binding-with-input-validation-how-to-enable-the-save-button-only). Please follow the link for a solution with an in depth code example. – Sheridan Apr 25 '14 at 14:03
  • Not sure if you call it "Exact" I want to know how to do this via a DataGrid, where that answer has nothing to do with that, so therefore really can't help me. But there you go. This is more of a "Exact" duplicate http://social.msdn.microsoft.com/Forums/en-US/9735ed75-822e-4689-ac8d-65d91435b977/datagrid-validation-disabling-a-button-mvvm?forum=wpf – user3428422 Apr 25 '14 at 14:27
  • If you can't extract information from one solution and apply it to yours, then you'll have real problems as a developer. You're not always going to have someone to tell you all the answers for your specific problem... sometimes you'll have to do some work yourself. There is enough information in the linked answer and MSDN for you to solve your problem... if you can be bothered. – Sheridan Apr 25 '14 at 14:34
  • I wasn't saying I wanted a exact answer, all I was questioning was your term "Exact", plus how was I am going to find that answer with the length of the question? Nevermind. Draw a line under it. – user3428422 Apr 25 '14 at 14:48

0 Answers0