Xamarin supports a subset of the .NET framework, but for the most part includes all the standard APIs you would expect in the .NET base class libraries. Because of this, a large portion of C# open source libraries can be used directly in Xamarin projects. Additionally, if an open source project doesn't have a Xamarin or portable class library version, many times porting the code yourself can be very straightforward. Xamarin also supports calling native Objective-C and Java libraries, so we will explore these as additional means of reusing existing code.
In this chapter, we will cover the following:
The primary and obvious way to add third-party components to your project is via the Xamarin Component Store. The Component Store is fairly similar to NuGet on Windows, except that the Component Store also contains premium components that are not free. All Xamarin components are also required to include full sample projects and a getting started guide, while NuGet does not inherently provide documentation in its packages.
All Xamarin.iOS
and Xamarin.Android
projects come with a Components
folder. To get started, simply right-click on the folder and select Get More Components to launch the store dialog, as shown in the following screenshot:
At the time of writing this book, there are well over 100 components available to enhance your iOS and Android applications. This is a great place to find the most common components to use within your Xamarin applications. Each component is complete with artwork, possibly a demonstration video, reviews, and other information you would need before purchasing a premium component.
The most well-known and useful components are as follows:
ActionBar
replacement for AndroidNotice that some of these libraries are native Java or Objective-C libraries, while some are plain C#. Xamarin is built from the ground up to support calling native libraries, so the Component Store offers many of the common libraries that Objective-C or Java developers would leverage when developing mobile applications.
You can also submit your own components to the Component Store. If you have a useful open source project or just want to earn a little extra cash, creating a component is simple. We won't be covering it in this book, but navigate to http://components.xamarin.com/submit for full documentation on the subject, as shown in the following screenshot:
18.188.252.23