1
votes

I have inherited maintenance and development over an app that was originally written without Xamarin.Forms, doing the UI layer for Android and iOS the traditional way with platform specific projects and a shared project for my business logic.

Given that most of the app screens are rather simple and I spend a disproportionate amount of time wrangling with platform specific UI code, I wanted to ask if anybody has experience with integrating Xamarin.Forms in a project that did not originally use Xamarin.Forms.

I was wondering if it was possible to replace specific screens with Xamarin.Forms, perhaps by hosting them manually inside the specific Android Activity or iOS Screen.

I would like to start out by integrating the next feature screen as a shared Xamarin.Forms "page".

Has anybody ever done anything like this before?

1
Interesting question. I have recently done the opposite, recreated all of the simple screens of a non-forms app in forms and attached the more complex ones as custom renderers. Is that an option for you? - Andrew Tavera
A total refactoring isn't an option at the moment, however a rolling refactoring is. Which is why I'd like to implement simple new additions in XF instead of native. We're speaking of a listview-with-a-searchbox-and-button kind of simple.The screens don't really interact with one another in any complex way. - bpylearner

1 Answers

2
votes

We have done this due a redesign of the app. We have developed the app with MvvmCross and native UI and moved to Xamarin.Forms. We threw away all views, but kept the ViewModels. That means: If the UI layer is decoupled from your ViewModel layer (using data binding), it should be easy to switch completely.

I would not recommend, mixing up Forms and native Activities/ViewControllers, because handling the navigation properly, can be a pain (especially under android). If there is something complex on one screen, you should move this in a custom element with a custom renderer.

For mixing up there are two minimalist examples: