Coffeehouse Post

Single Post Permalink

View Thread: MVVM
  • User profile image

    spivonious said:
    spivonious said:

    Okay, I think I have a basic MVVM app working. Here's how it's set up:

    Model - for this I just used the strongly-typed DataSet class. I added methods to support my commands directly to the class file.

    ViewModel - this contains an instance of the DataSet and properties matching up to all of the tables in the DataSet, as well as instances of Josh Smith's RelayCommand.

    View - this is standard XAML with zero code-behind. I added <Window.DataContext><MainViewModel/></Window.DataContext> to the XAML, getting rid of the need to set the datacontext in code.

    Did I do things right? This will at least get me table-level abstraction.

    There's any number of things you could have done differently, but you did it "right" as far as what's needed by the pattern.  Please not I'm not suggesting there's anything I'd do different, just pointing out there's a lot of different takes when it comes to implementing the pattern.  Things like "View first" (which is what you did) and "ViewModel first", for example.

    If there's no business logic in the code behind, minimal to no UI code in the code behind, and you have a testable ViewModel, you've done things "right".