New to Xamarin

xceedxceed GBMember ✭✭
edited June 2014 in General

Hi all, I've just installed Xamarin Studio and so far I'm enjoying working with it.

Maybe I've completely missed the point but I thought I'd post to clarify something... So currently I have a full native Windows Phone 8.0 app and now want a native (or as close to as possible) Android version.

Am I right in thinking that I'll need to completely re-write my current WP8.0 app from scratch in Xamarin Studio? But then once I've done that I'll have working Windows Phone and Android versions? And that's good as I'll have one codebase where I can make changes but only have to make the changes once (as opposed to twice if I had 2 separate native versions for each platform).

That's my understanding so far, does that make sense/seem like the right way to go about it?

Thanks

Posts

  • JasonAwbreyJasonAwbrey USInsider, University, Developer Group Leader mod

    How much you have to rewrite depends on how well your app is architected. If you have your UI code separated from your backend (domain, data, service) you can probably re-use the backend with minimal rewriting. Then all you have to completely rewrite in your UI layer.

  • KMullinsKMullins USMember, Xamarin Team Xamurai
    edited June 2014

    Hi @xceed‌,

    First glad to hear that you are enjoying Xamarin! Like so many of my fellow Xamarins, I started out as a customer and loved the product so much I ended up as an employee!

    You shouldn't need to completely re-write your current WP8.0 app as much as you'll need to reorganize it... basically take all the non-UI and platform specific bits and move them into a "shared library". From there it is a matter of creating platform specific UI clients and consuming your backend code. Using this technique, most of our customers are able to get up to 80% code reuse across platform.

    There are several different ways that you can use to slice up your code and share it across platform. We have several documents that should help you pick the best method for your specific application:

    Hopefully the above will get you off to a good start. If you have any questions, please let me know.

    Thanks,

    Kevin

  • xceedxceed GBMember ✭✭

    Thanks @KMullins, I've got a better understanding now, think I'm going to go with the PCL option as with my WP8.0 app I already have a class library (since I'm using a background scheduled task agent I had to separate out a few things).

    So the main chunk of work I'll need to do as new will be to create all the views for the Android version and all associated event handlers. I've got some business logic inside some of my WP8.0 event handlers that could do with moving to the PCL.

    Still, it'll be quicker than starting from scratch with Android then having 2 distinct versions for 2 different platforms to maintain.

    Thanks again.

  • KevinMullinsKevinMullins USMember, Beta ✭✭

    @xceed,

    Glad to hear that you have a better idea of how to proceed. One other thing that I forgot to mention is Xamarin.Forms our new cross-platform UI construction kit.

    Xamarin.Forms is a cross-platform natively backed UI toolkit abstraction that allows developers to easily create user interfaces that can be shared across Android, iOS, and Windows Phone. The user interfaces are rendered using the native controls of the target platform, allowing Xamarin.Forms applications to retain the appropriate look and feel for each platform.

    Depending on the type of application that you are creating, you might be able to create your UI in it and share even more of your source code across platform.

    For more information on Xamarin.Forms, check out this document: An Introduction to Xamarin.Forms

    Again, good luck and please let me know if you have any questions.

    Kevin

  • xceedxceed GBMember ✭✭

    Yep, I've been reading up on Xamarin.Forms, but how does it work with event handlers? I can have one event handler for both platforms? As long as the event handler works with the PCL?

  • CharlesPetzold.4997CharlesPetzold.4997 USXamarin Team Xamurai

    I think I understand the question, but let me take a shot:

    If you'll be using Xamarin.Forms, you'll be constructing a user interface using Xamarin.Forms controls such as Button and Slider in the PCL. These controls fire events such as Clicked and ValueChanged. The handlers for these events are also in the PCL.

    If you have some platform-specific code in the WP project or in the Android project, and if that platform-specific code files events, the event handlers for those events can also be in the PCL.

Sign In or Register to comment.