0
votes

I'm developing a WPF application which reads and writes XML data.

I'm coming from an MVC background and I want to take an MVVM approach.

In the last MVC project I worked on I would use the repository pattern to get the data. The Controller would have an interface to a Service which would in turn have an interface to the Repository. The repository would get the data and return it back to the controller which would populate a ViewModel to be passed to the View.

I'm wondering

  • Should I should take a similar approach here?
  • Should I implement a Repository Pattern.
  • If so, would I have an interface to the service in e.g. a button click event?
  • Should I populate the ViewModel in the button click event or in the Service?

If I shouldn't use the Repository Pattern, what's the best approach for retrieving the XML data?

1

1 Answers

0
votes

In previous MVC applications I've built I put view/edit models in a seperate dll to help clear up the controller. The service (facade for domain operations) would map domain objects to the view/edit models and pass them back to the calling controller.

If you do wish to use a repository pattern, I'd populate the models in the service - this allows all such operations to be contained within one place, rather than fragmented amongst various click events.