Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
Cross-platform UI Development with Xamarin.Forms
Cross-platform UI Development with Xamarin.Forms

Cross-platform UI Development with Xamarin.Forms:

Arrow left icon
Profile Icon Paul Johnson
Arrow right icon
Mex$179.99 Mex$771.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.7 (7 Ratings)
eBook Aug 2015 330 pages 1st Edition
eBook
Mex$179.99 Mex$771.99
Paperback
Mex$963.99
Subscription
Free Trial
Arrow left icon
Profile Icon Paul Johnson
Arrow right icon
Mex$179.99 Mex$771.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.7 (7 Ratings)
eBook Aug 2015 330 pages 1st Edition
eBook
Mex$179.99 Mex$771.99
Paperback
Mex$963.99
Subscription
Free Trial
eBook
Mex$179.99 Mex$771.99
Paperback
Mex$963.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Cross-platform UI Development with Xamarin.Forms

Chapter 2. Let's Get the Party Started

This chapter is primarily involved with the introduction of the Xamarin Forms library, and its incorporation within your applications. In particular, we will cover the following topics:

  • Setting up for Xamarin Forms

  • How Xamarin Forms work

  • Adding a Windows Phone project to your app

What is Xamarin Forms?


Xamarin Forms is known as a user interface abstraction library. It operates as a Portable Class Library (PCL), sitting on the target platforms and feeding in the UI elements that the application needs. It is as good as it sounds! Application user interfaces can be quickly constructed as a large amount of any other code can be shared.

Note

The Xamarin Forms library also allows you to access the platform hardware through injection with UI customization, through custom renderers. Both of these topics are covered later in the book.

Being an abstraction layer, only those elements with an analogous element on all of the target platforms are covered. For example, at the time of writing, there is not a single checkbox in forms and graphics on tab pages, for Android gives nothing.

This library is also part of a PCL. The PCL itself only supports a subset of the standard .NET library classes, namely those that are supported on all platforms. This leads to quite a few issues, such...

Instantiating Xamarin Forms within an app


We instantiate Xamarin Forms within each supported platform of the app. Xamarin Forms support the following platforms:

  • Android

  • iOS

  • Windows Phone

Android

Typically, an activity to start an activity class looks like this:

public class MyActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
         base.OnCreate(bundle);
         // then whatever you need to do

To start a Xamarin Forms app, this changes as we are not inheriting the Activity but a FormsApplicationActivity, or more precisely:

public class MyActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
    protected override void OnCreate(Bundle bundle)
    {
         base.OnCreate(bundle);
         global::Xamarin.Forms.Forms.Init(this, bundle);
         LoadApplication(new App());
    }
}

iOS

As with Android, we inherit FormsApplicationDelegate in AppDelegate instead of the usual UIApplicationDelegate:

[Register("AppDelegate")]
public partial class AppDelegate...

Dependency injection


Another important aspect of Xamarin Forms is based on something called Inversion of Control (IoC).

Inversion of Control?

Once the app has started, the PCL runs the show; it is in control. However, certain things have to use the device or facilities on the device, and so control is passed to the application (control has been inverted). This can be considered using the following diagram:

https://jonlennartaasenden.files.wordpress.com/2015/01/traditional-vs-di.gif

IoC and Dependency Injection go hand-in-hand. DI (as the name implies) injects information directly into the PCL. There is a rule, though, to do this: the class being called must have a default constructor for the class (normally, the default constructor for any class is not required).

Implementing DI

Let's take the following example for DI. A PCL only contains a subset of the standard libraries; one important omission is anything to do with the filer. When you create a SQLite database though, a file has to be written...

Customizing the UI


While the basic UI elements are available, to do anything interesting (such as customizing buttons), a custom renderer has to be created. These are covered fully in Chapter 6, A View to a Kill, which deals with the user experience, as well as other places within the book.

Gestures, maps, and WebViews


Gestures, maps, and WebViews are very commonly used user-interface facilities. While they are all in Xamarin Forms, we will see that they are not as extensive as if they were native versions.

Gestures

All mobile devices have some form of a sweep system. The iOS is especially rich when it comes to having a multi-touch user interface. As with everything to do with Xamarin.Forms, it only covers the basic type of touch, essentially the only one supported on all platforms.

Note

Code for the following is given in Chapter2/Gestures.

Gestures are not enabled on all types of gadgets (for example, gestures are not enabled for dragging pins on a map). This is because only tap detection is currently supported.

Adding a gesture recognizer

In this example, we'll add a gesture recognizer to a label. Labels usually don't have a click event.

  1. Let's create the label:

    var count = 0;
    
    var label = new Label()
    {
      Text = string.Format("You have clicked me {0} times", count),
      TextColor = Color...

Summary


From the get-go, Xamarin Forms gives you the ability to create an app on the three main mobile platforms without many problems. Most of the standard UI elements are present, and enable the production of feature-rich applications. As we will see in later chapters, using custom renderers as well as being able to access the hardware-specific facilities can extend applications.

In the next chapter, we'll be looking at how we can improve upon the user experience by modifying the user interface to make it more friendly and intuitive.

Left arrow icon Right arrow icon

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 26, 2015
Length: 330 pages
Edition : 1st
Language : English
ISBN-13 : 9781784394370
Vendor :
Microsoft
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Aug 26, 2015
Length: 330 pages
Edition : 1st
Language : English
ISBN-13 : 9781784394370
Vendor :
Microsoft
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Mex$ 2,645.97
Mastering Xamarin.Forms
Mex$676.99
Mastering Cross-Platform Development with Xamarin
Mex$1004.99
Cross-platform UI Development with Xamarin.Forms
Mex$963.99
Total Mex$ 2,645.97 Stars icon
Banner background image

Table of Contents

14 Chapters
In the Beginning… Chevron down icon Chevron up icon
Let's Get the Party Started Chevron down icon Chevron up icon
Making It Look Pretty and Logging In Chevron down icon Chevron up icon
Making Your Application Portable Chevron down icon Chevron up icon
Data, Generics, and Making Sense of Information Chevron down icon Chevron up icon
A View to a Kill Chevron down icon Chevron up icon
Connect Me to Your Other Services Chevron down icon Chevron up icon
What a Bind! Chevron down icon Chevron up icon
Addressing the Issue Chevron down icon Chevron up icon
This is the World Calling… Chevron down icon Chevron up icon
A Portable Settings Class Chevron down icon Chevron up icon
Xamarin Forms Labs Chevron down icon Chevron up icon
Social Media into the Mix Chevron down icon Chevron up icon
Bringing It All Together Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.7
(7 Ratings)
5 star 42.9%
4 star 14.3%
3 star 28.6%
2 star 0%
1 star 14.3%
Filter icon Filter
Top Reviews

Filter reviews by




Enaut Manterola Mar 01, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great!
Amazon Verified review Amazon
ANH QUAN HOANG Sep 22, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a good books for anyone looking to get started in using Xamarin platform. It corners many topics from the most basic, creating a simple button, to getting you app set up for push notifications. This book also discussed "delegates" and "customrenderer" which allow Xamarin a certain degree of flexibility. If you are family with C# and are interested in mobile development, then this book is a must read.
Amazon Verified review Amazon
Taskos George Oct 06, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Another great delivery from Paul F Johnson, this is a great book to start and get familiar with all the aspects of Xamarin Forms, even if you are already started using the technology an intermediate mobile developer will find many topics that will take him to the level needed. Great explanations in all related technologies involved.
Amazon Verified review Amazon
Sparagis Elias Sep 24, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
As a Xamarin Certified Mobile Developer, I have been with Xamarin.Forms since its first stable version and I can tell for sure, that it is very difficult to fit in one book the required knowledge for starting building cross-platform applications.The book Cross-platform UI Development with Xamarin.Forms by Paul F.Johnson, is a book that simply touches the great aspects and concerns of of starting building apps with the Xamarin.Forms. It is not a cookbook or a walkthrough (step-by-step) guide for Xamarin.Forms and it is quite certain that proper knowledge of the platform is advised in order to follow each chapter.I really enjoyed every chapter, because it really contains practical and useful knowledge not only for constructing a better UI but also to fully understand the cross-platform constructing process.I surely recommend it to native android or ios developers that want to find some quick answers for the Xamarin.Forms and its capabilities, before diving deeper in the platform.
Amazon Verified review Amazon
Amazon Customer Oct 07, 2015
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
A pretty good book that does a good job of introducing Xamarin Forms. He even covers the limitations of using PCL's (i.e. pointing out how some IO classes are not available) - little things like that can be very confusing when you're first starting out and expecting them to be there. He also covers setting up IOS provisions, push notifications and using maps. Features such as this involve a lot of knowing-where-to-go-just-to-point-and-click-a-checkbox and identifying those paths on your own can be quite frustrating so its nice to have a guide. Also covers a bit of Azure and a quick intro on Xamarin Labs. I could've done without the brief foray into his forensics past and building the time of death app but thats just my own personal idiosyncrasies. Overall a good intro book doesn't go deep like Petzold's book but you'll definitely walk away know a few things.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.