I'm writing a WPF application using MVVM. I'm trying to understand how to use correctly this pattern for what concern validation. For example, my application will manage data about articles. When a user will insert a new row, a first-step validation will mark controls needed, such as article code, quantity, description, vat...
But there is a second step validation executed by the model: for example I should check that code article will be available from vendors. I need to call one (or more) webservice and this operation can be done only by the model. Well, when I get an incorrect result (ie, article not available) I need to return it to the viewmodel and to the view. I'd like not to show only a message, in this case I'd like to adorn code article textbox... or I'd like at least to set focus on textbox!
But... how can I do without "break" mvvm pattern? The model can return the string result, but model don't know anything about viewmodel and viewmodel don't know anything avout view... so... when I get the result from the webservice, I can return string result, I could show a messagebox with string result, but how can I refer to the code article textbox in the view in order to set focus or adorn textbox with a redline?
Obviously, this is only an example, the question is if is possibile to create a "link" (through binding?) between data passed to vm-m and controls in the ui...