Two view-models, each for a separate screen, have an ICommand which has same logic: it needs to choose between asking the user to choose from a list of items or choose an item automatically.

How should the two view-models share this common ICommand?

Should I create an ICommand derived class where I put this logic? I don't think so, commands should not have this kind of logic I think. I think I need to use a separate 'thing', but I don't know what that should be.

  • Extract common logic in separate function then use this function inside both commands. – Fabio Oct 7 '17 at 19:11
  • OK. but where does that function live? Which component \ class? – Daniel Oct 7 '17 at 21:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.