AnsweredAssumed Answered

Confusing - MVVM WPF and Commands

Question asked by earnshawgetech on Oct 31, 2019
Latest reply on Nov 4, 2019 by earnshawgetech

Sorry, I'm getting totally confused with WPF and how it works with MVVM and ESRI's SDK. I need to know where the most helpul, most appropriate resources are for this kind of development.

 

At the moment I'm getting hung up over Commands and ArcGIS.Desktop.Framework.Controls.ProWindow.  It's just a simple user login interface and trying to figure out how the Login button should activate/light up.  Obviously I want to enable it when the user enters a username and password - but it's so confusing when you try to implement a command -

 

      
  1. Should I just use simple code behind?
  2.   
  3. Should I build out an elaborate MVVM solution of my own making?
  4.   
  5. Should I use Prism or ActiPro or some other 3rd Party library?

 

When you start binding objects its hard to know which way you should bind, do you do it all in the XAML or all in code or a bit of both, what is the right way? There is no obvious way despite looking at tons of different tutorials and videos on the subject. Everyone has a slightly different way of doing things.

 

Main Question

How do you pass a binded object for evaluation through the command implementation? That is, the object is a "User" which is the Model (wrapped up in the ViewModel class) and has properties or Username, Password, PortalUrl - the UserViewModel comprises the User object and exposes it's inner properties of the User object so it can bind - but then I find it confusing trying to use a Command to check the object to see if its valid (i.e. completed out username/password/portalurl).

 

Maybe I am over complicating things for something this simple, but on the other hand I want to do things the right way and not just hack something together. In the end I will be putting together a more complex UI and I will need to know this stuff in any case so I may as well learn it now with something simple.

If anyone can help put me on the right track I would appreciate it.

Outcomes