0

A person asked me to write a application in MVC style(I know what MVC is and I used this pattern in desktop applications) in Windows Phone. But Windows Phone is kinda different. We have xaml where we declare design of the page and corresponding class of the same name.

Would it be(in this particular situation) that the View is a X.xaml file Controler is a X.class file and I need to create another class which will be Model?

Am I right or wrong? If wrong what is wrong?

Yoda
  • 15,011
  • 59
  • 173
  • 291
  • 2
    Why not use [MVVM](http://en.wikipedia.org/wiki/Model_View_ViewModel)? It's a pattern that also separates concern and there's a lot of support for it on WP. iOS focuses on MVC but MVVM is generally the accepted pattern on WP. [Here's](http://stackoverflow.com/questions/667781/what-is-the-difference-between-mvc-and-mvvm) a thread explaining the differences. There is an [MVC framework](http://windowsphonemvc.codeplex.com/) available on CodePlex but I haven't used it so can't comment on it. – keyboardP Sep 13 '13 at 22:22
  • 1
    @keyboardP The question is about MVC not alternatives to it. I was asked about MVC. – Yoda Sep 13 '13 at 22:48
  • Other than a few other separations of concerns and better framework support in WP, MVC and MVVM aren't super different. I suggest reading the links provided to get an idea of how things are done in WP and then try to adapt them. For the most part, though, the xaml would be the `view`, the code behind that would be the `controller`, and you would need to create whatever models are needed. – legacybass Sep 13 '13 at 23:03
  • @Yoda - Which is why I didn't post it as an answer :) Just posted in case the person who asked or you are coming from iOS and unaware of MVVM, I thought I'd mentioned the alternative that's usually used on the platform. – keyboardP Sep 14 '13 at 09:52

1 Answers1

1

For you clarification yes you are absolutely right

your folder structure will be something like Model -> containing classes which will help you map you to the data base View -> containing all you xaml and xaml.cs files as in aspx and all Controller -> contains all cs files where manipulation and logical works are done.

But there are few drawbacks of using this. Try managing memory properly and not send large chunks of data from one page to other. In a limited memory device app will behave slowly. Every time you call a controller cas you will have to send data from xaml.cs to the controller so code it wisely. :)

Anobik
  • 4,661
  • 2
  • 14
  • 32