Monday, January 11, 2016

Compatibility: Xamarin Forms 2.0 and UI for Xamarin by Telerik

The new year brings new changes to the Xamarin framework, and most notably the Xamarin Forms abstraction library. With the release of Xamarin 4 and Xamarin Forms 2.0, we have inclusion of Material Design for Android, a new API for ListViews, enhancements for Windows Phones, lot of extras and of course much needed bug fixes. It's a solid release, and looks to make the use of XF even more efficient. The upgrade looks perfect for what is in demand right now.

Sounds good, but I still dislike messing with the visual design. Are there any other options?

Enter UI for Xamarin by our friends at Telerik. Although the Android and iOS libraries were presented previously, support for Xamarin Forms was released in late 2015 with a basic set of controls. More are being added quarterly. They bring the familiarity and ease of their Rad controls to a Xamarin mobile app (if you have had any experience implementing them on .Net applications, they are second to none in quality). You can find out more about the plugin here.

Fantastic! I'm sold. Plugin trial downloaded, Xamarin project started, I'm only gonna focus on Android for now. Adding the plugin references and... wait, why won't my project build?





















At this time, UI for Xamarin is compatible with the previous version of Xamarin Forms. Since 2.0 is so new that it just came out, Telerik has not had a chance to test their plugin against it and make it compatible. Do not be dismayed, fellow developer. It is still possible to try out the suite of controls with a few extra steps (which ultimately should be fixed in the next release).

Things you need to know:

  • When you download Xamarin 4, you get Xamarin Forms 2.0
  • If you use the Visual Studio plugin for Xamarin, the project templates have old references to XF, so a package update via NuGet would be necessary anyway
  • Telerik's UI for Xamarin compatibility is only for Xamarin Forms version 1.5.1.6471 [reference]
  • You will need the most recent Android SDK (API 23) installed


How to run UI for Xamarin in Xamarin 4


For this example, I choose to set up the app for the Telerik Xamarin Forms ListView control.

1. Create a blank Xamarin Forms Portable app in Visual Studio



2. Uninstall the existing version of Xamarin Forms that is shipped with the visual studio project template. Note the version.





3. Install the Xamarin.Forms NuGet package (must be version 1.5.1.6471 - done through the Package Manager Console in Visual Studio) to the PCL and platform-specific projects. See NuGet command.




4. Add references to the UI for Xamarin Forms controls from Telerik to the PCL and platform-specific projects as you need them. Read the API documentation for specifics about using the ListView control, for example.



5. Pay close attention to what additional NuGet packages are required for the Android project to get up and running using Xamarin.Forms. There is an excellent blog post on installing the necessary references for the Telerik ListView for Xamarin Forms here.



6. Build the project to make sure you are ready to proceed with building your app. If you still find issues building, make sure to clean and build. It may also be necessary to open the bin folder of your Android or iOS project and delete anything that was previously in the Debug folder before building again (thanks to the Xamarin Forums for that suggestion). I only ran into that once at the beginning of this process. After that, no problems with running the Android app.

Eureka! We got a welcome screen. Is this something that could happen again, or just for this version?


Always Be Prepared


Handling compatibilities between software can be a bit of a bear, to be sure. With the ever-changing landscape of mobile apps, we want the growth and enhancements to occur. Seldom does it come with easy integration into existing technologies. But take heart! It won't be long before subsequent min versions should be able to clean that up for us. In the meantime look at it as an opportunity to examine how the fabric of a Xamarin Forms application is woven together with third party plugins. Knowledge that will certainly serve you well in the future.






1 comment:

  1. This an informative and helpful post so clear and easy to follow step by step on Compatibility: Xamarin Forms 2.0 and UI for Xamarin by Telerik. All your hard about curating this informative post that helps Xamarin Developer is much appreciated.

    ReplyDelete