0

The team I'm on created a cross-platform application that runs on iOS, Android, and Windows Mobile that was created using Xamarin's tools and MonoCross. We're looking at MvvmCross as a possible MonoCross replacement but don't want to write the application from scratch.

Does anyone have experience with or thoughts on migrating a Xamarin/MonoCross cross-platform application to Xamarin/MvvmCross? Is it possible for the two frameworks to coexist in the same app (the ideal solution would have us migrate the app one screen at a time).

Thanks in advance.

billmaya
  • 1,311
  • 3
  • 15
  • 34

2 Answers2

2

Following Stuart's advice below I confirmed that it is possible to integrate MvvmCross into an existing MonoCross application.

In the original code a selection on View 1 initiates a call to Controller 2 using MonoCross URI navigation. Controller 2 displays View 2, passing it the data from Model 2.

enter image description here

Following the example in this video I created an MvvmCross View and ViewModel. A selection on View 1 still navigates to Controller 2 but Controller 2 now displays the new MvvmCross View 2. View 2 is data bound to ViewModel 2 which takes over Controller 2's functions of getting the Model data.

enter image description here

billmaya
  • 1,311
  • 3
  • 15
  • 34
  • I understand your diagram, but don't understand how to actually make it work. Can you provide any other details on how you got MonoCross navigation to get to MvvmCross views? – Michael Mar 05 '14 at 21:30
  • I got this to work, but I'm not crazy about it. My MvvmCross views had to implement IMXView, even though I'm not even doing anything with it. Also, in the view constructor, I'm having to manually call CreateBindingContext() and do "DataContext = Mvx.IocConstruct();". It can then navigate to my view, and the binding functions, but I don't know if there is a better way. – Michael Mar 06 '14 at 16:40
  • One more note for others... I also had to create a MonoCross controller with a default route I can register, in order for navigate calls to go to my MvvmCross view as well. Once fully on MvvmCross, those classes would be removed. Again...seems hacky though. – Michael Mar 06 '14 at 16:55
0

I don't know of anyone who's done this recently, but I originally ported several of the MonoCross samples over when I first created MvvmCross. The overall idea of one page to one "ViewModel" stays the same, although the mvvm binding offers more continuous view-viewmodel interactions than the more discrete Controller-Action model.

At a practical level:

  • MvvmCross itself is very modular and can be used in "CrossLight" mode where it simply provides data-binding and plugins - see CrossLight in http://mvvmcross.wordpress.com/. You might be able to use this for migrating pages one-by-one
  • MonoCross isn't really very interface/IoC based - so you may find that your resulting MvvmCross migration would also not be interface based either
  • MonoCross apps tend to use file-linking and #defines rather than PCLs - so you may find it easier to not use PCLs in MvvmCross

I suspect the best option for this migration is to let your team experiment - they already have lots of knowledge about your app and about what they do and don't need and what benefits they do and don't get from a framework.

Stuart
  • 66,722
  • 7
  • 114
  • 165
  • Stuart, I would love to see a new sample showing how you recommend MonoCross users can slowly migrate to your framework. If you have anything to add to my comment above about integrating MvvmCross into my existing MonoCross app, I would really appreciate it. – Michael Mar 06 '14 at 16:43
  • Sorry - I've not really migrated any monocross code in 2 years now - not since the original samples - so I don't really have anything to add. in fsct, I've not really even seen any monocross samples for 2 years - so not sure what the required steps are - sorry! – Stuart Mar 06 '14 at 18:08