How to implement MVC Architecture in Xamarin Studio for developing Cross Platform Application?

deeptideepti USMember
edited June 2015 in General

Hi, i am beginner in Xamarin Studio and want to know how we can implement MVC architecture in Xamarin Studio for developing Cross Platform Applications using c#?

Answers

  • KMullinsKMullins USXamarin Team Xamurai

    Hi @deepti,

    I suggest you start with this documentation first: Building Cross-Platform Applications

    It has quite a few sections and goes into great detail.

    Thanks,

    Kevin

  • deeptideepti USMember

    @KMullins : Thank you so much :)

  • VishnuPSVishnuPS USMember

    @KMullins is there any MVC Framework exists for xamarin.forms code first approach? thanks in advance!

  • CharlesPetzold.4997CharlesPetzold.4997 USXamarin Team Xamurai

    The MVVM pattern is much more suitable for Xamarin.Forms, and Chapter 18 of Creating Mobile Apps with Xamarin.Forms is dedicated to MVVM: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/creating-mobile-apps-xamarin-forms/

  • LarryOBrienLarryOBrien USXamarin Team Xamurai

    I'm a big fan of the MVC architecture and personally think it's entirely appropriate for cross-platform development. Do you have specific questions?

    On iOS, a fairly classical MVC architecture is facilitated by the SDK: UIViewControllers and their descendants are Controllers and UIViews and their descendants are views

    On the Android side, the mappings a little harder, because of Intents, which aren't as coarse as traditional Controllers. (To me, the fascinating thing is that the Android native architecture is one I'd only ever seen before in server clusters. The nice thing about that architecture is that you can scale it so that responsibilities are handed off to other processors and even if they fail you can be resistant to crashes, etc. But I digress...)

    In Xam.Forms, a Page is the Controller, while Views are, well, you know. With Forms, we have an MVVM architecture, but you can still make the choice to have the more classic MVC data-flow where the View reflects the Model directly (via binding, with MVVM) rather than the (IMO) often-problematic MVP data-flow in which the Controller/Presenter is in the middle.

  • Gera88Gera88 DEMember

    @LarryOBrien said:
    I'm a big fan of the MVC architecture and personally think it's entirely appropriate for cross-platform development. Do you have specific questions?

    On iOS, a fairly classical MVC architecture is facilitated by the SDK: UIViewControllers and their descendants are Controllers and UIViews and their descendants are views

    On the Android side, the mappings a little harder, because of Intents, which aren't as coarse as traditional Controllers. (To me, the fascinating thing is that the Android native architecture is one I'd only ever seen before in server clusters. The nice thing about that architecture is that you can scale it so that responsibilities are handed off to other processors and even if they fail you can be resistant to crashes, etc. But I digress...)

    In Xam.Forms, a Page is the Controller, while Views are, well, you know. With Forms, we have an MVVM architecture, but you can still make the choice to have the more classic MVC data-flow where the View reflects the Model directly (via binding, with MVVM) rather than the (IMO) often-problematic MVP data-flow in which the Controller/Presenter is in the middle.

    Could you point me to an example using MVC architecture with Xamarin.Android?

  • JTSoftwareJTSoftware USMember ✭✭

    Could you guys please port some subset of MVC 5 for mobile? It seems it would make converting web apps to mobile much simpler, not to mention simplify form-based apps in general. I have a huge MVC 5 ASP.Net web app, and I want to port a chunk of it (maybe 20% - sans editing ability) to an offline phone app, but I don't have any phone development experience. I was glad to find you have a razor implementation, but it seems to be without many of the features I need, such as layouts, RenderPartial, etc., which would almost allow me to start from my existing .cshtml sources. I'm curious as to why this wasn't done, as it seems a no-brainer. (Too big and complicated maybe? I'm looking at the sources--pretty hairy.) Otherwise, if there is something out there like this, could someone point me to it? Otherwise I'll have to hack up something myself.

  • JTSoftwareJTSoftware USMember ✭✭

    I finally found the PortableRazor library and sample, which is a great start. However, it's missing some features I consider essential, such as layouts and RenderPartial.

Sign In or Register to comment.