Gerald Versluis and Steven Thewissen
Xamarin.Forms Solutions
Foreword by David Ortinau
Gerald Versluis
Hulsberg, The Netherlands
Steven Thewissen
Hulsberg, Limburg, The Netherlands
ISBN 978-1-4842-4133-2e-ISBN 978-1-4842-4134-9
Library of Congress Control Number: 2018964067
© Gerald Versluis and Steven Thewissen 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Foreword by David Ortinau

I love working with teams to build mobile apps, and to help make the whole process better. Working with Microsoft on Xamarin and mobile developer tools is the perfect fit for me. The work keeps me up at night laboring to solve some nagging issue blocking a customer, and it gets me up early in the morning to push forward. Day in and day out, that work ends up being a lot of screen time!

A few years back, I started venturing into the great outdoors where I could for a brief time leave all my work behind. I recall my first time hiking on a single-track trail only 1.5 miles from the nearest road, house, or human; a wave of panic came over me. I looked at my phone and prayed to see bars. Phew, I was okay. But what if I sprained my ankle? What if I ran out of water? What if I saw a bobcat? (I live in Missouri —that’s about as dangerous as it gets at the foothills of the Ozark Mountains.)

I realized if I was going to spend more time in the woods and get farther and farther from civilization, I needed to know what to do in emergency situations and how to sustain myself. As my goals went from two miles to 10 to eventually 50 miles, the planning and the knowledge I needed to be successful grew and grew.

The first book I picked up was a survival handbook with practical advice such as how to escape a mountain lion, and not so practical advice such as how to survive jumping from a building into a dumpster. I talked to others whom I met out on the trails, I read a lot of blogs, and I watched a lot of YouTube. I learned valuable lessons all along the way.

A while later, I did see a coyote and it was enormous! I quickly texted my hiking friend who had hiked part of the Appalachian Trail the previous year about what to do, and he replied: “Back away slowly, makes some noise so he knows you’re there, and just keep moving. Make a lot of noise if comes toward you.” Phew! Good advice, and the coyote went bounding away.

Perhaps for you the questions are more like: “How do I make my Entry field look and work like this design?” or “How do I do barcode scanning in Xamarin.Forms?” or any number of other common questions. As I look at his book, I see a great success guide for mobile developers. It will answer many of your questions and help you like those survival guides have helped me.

Steven is a long-time Xamarin developer and community advocate known for blogging about how to make beautiful apps with Xamarin.Forms. Gerald is a recognized Microsoft MVP and an active contributor to Xamarin.Forms. Steven and Gerald should be on the top of anyone’s list to call when that “coyote” surprises you in the middle of your day.

If you heed the guidance in this book, you’ll not only survive your project, but you’ll thrive! As you master the fundamental lessons, the book becomes a great resource to grab code samples from that help solve the common challenges along your way to building and shipping better and bigger apps more quickly.

—David Ortinau

Introduction

First of all, we would like to thank you for acquiring this book. Hopefully you will enjoy reading it as much as we enjoyed writing it.

This book is all about Xamarin.Forms. We have tried to provide you with a very complete reference on this matter. Whether you are a starting developer or a more seasoned one, this book should hold useful information for anyone.

We will start you off by going over the basic fundamentals of Xamarin.Forms. You will learn about renderers, which are at the heart of Forms. These renderers perform the translation between abstract controls and the native controls. You also have the possibility to hook into that and write so-called custom renderers. You will also learn how to leverage platform-specific code in a shared code context. This is accomplished with the DependencyService that is built-in right into Xamarin.Forms. This and much more is just in the first chapter.

From there, we will target the user interface. Contrary to popular belief, you can create beautiful UIs in Xamarin.Forms. We will provide you with all the information and tools to do that for yourself. We will see what options there are to create layouts and how the elements work in-depth. Of course, data is something you cannot do without, so we will show you how you can influence the way your interface looks based on that data. Other things that you will learn are working with animations and custom fonts and how to create reusable controls that you can not only share within your project, but even across projects!

In the remaining chapters you will find all kinds of solutions for various scenarios. All of them conveniently categorized into a couple of chapters. As already mentioned: we can’t do without data. Therefore, a good understanding of how to get that data into our app and update it through data-binding is crucial. We learn how to show data, how to transform data through value converters, and how to show repeatable data in the ListView control.

To retrieve this data, a network connection is very important. Because of that, we have also included a whole chapter full of solutions that cover network and security. It teaches you how to connect to a backend and how to save code while doing so. We learn how to check our connectivity, cache data so we don’t impose unnecessary costs on our users, save data in a secure place, and deal with an unstable network.

Toward the end of this book you will encounter more common real-life scenarios. Think about showing a PDF file and scanning or generating barcodes but also how to version your app and collect crash reports and analytics from your app when it is released. To top it off, there are some advanced topics. Xamarin.Forms app can be a bit bulkier in file size than true native apps. You will learn how to shave off some of that extra size. Also, with the transition from PCL libraries to .NET Standard, you might want to look into converting your shared code in that area. We will teach you how to do just that and much, much more.

It would be impossible to cover everything about everything, but with this book in hand, we hope to provide you with a solid base. Based on our years of hands-on experience, we have tried to identify the most frequently asked questions and capture the solutions in this book. Hopefully we will be able to transfer all this knowledge to you through the means of this book and enable you to do amazing things and build great apps.

Acknowledgments

We would like to take some time to thank all of the people who made it possible for us to write this book.

First and foremost, our loving spouses Nadia and Laurie. Without them keeping the little munchkins out of our hair so we had the time to write, we would not be where we are today. They were just as important in completing this book as we were.

Also, our strict but very fair technical reviewer, Pieter. We know you have put in a lot of time to check and recheck every word, even in the code blocks. What really stood out to us is that you did not just point out mistakes and errors, but you also gave positive notes on the parts you liked. Thank you for taking the effort to make this book better.

A proper book cannot do without a wonderful foreword. For that, we were honored to have none other than David Ortinau write that for us. We are thankful that you could find time for us in your busy schedule to read our drafts. It really is the icing on the cake to have your foreword in this book.

From Apress, we would like to thank the entire publishing team, but Jill and Jonathan in particular. They have been there to guide us through this entire process and have been looking out for us along the way.

Table of Contents

Index 275

About the Authors and About the Technical Reviewer

About the Authors

Gerald Versluis
../images/469504_1_En_BookFrontmatter_Figb_HTML.jpg

is a developer and Microsoft MVP from the Netherlands with years of experience working with Xamarin, Azure, ASP.NET, and other .NET technologies. He has been involved in numerous projects, in various roles. A great number of his projects are Xamarin apps. Not only does Gerald like to code, but he is keen on spreading his knowledge as well as gaining some in the bargain. He speaks, provides training sessions, and writes blogs and articles in his spare time.

 
Steven Thewissen
../images/469504_1_En_BookFrontmatter_Figc_HTML.jpg

is a developer and Microsoft MVP from the Netherlands focusing on Xamarin, Azure, and other .NET technologies. He started working with Xamarin in 2014, and has been in love with it ever since. Steven shares his knowledge by regularly writing blogs about topics that interest him. He loves to push the boundaries of what’s graphically possible with Xamarin.Forms due to his interest in UI design. He loves to create kick-ass user interfaces to accompany his mobile apps.

 

About the Technical Reviewer

Pieter Nijs
../images/469504_1_En_BookFrontmatter_Figd_HTML.png
is a Belgian .NET architect with a passion for mobile and cloud development. He has played a key role in several projects, ranging from large consumer-facing telecom and media apps to smaller LOB applications. As he is primarily interested in the Microsoft stack. His interest and expertise translate to technologies like .NET, C#, Xaml, Xamarin, UWP, Azure, Visual Studio, TFS, VSTS, and more. Both at work as well as in his spare time, Pieter is constantly working and playing with these and other new technologies. He likes to tell everybody about the things he does, sharing his knowledge. You can find him speaking at conferences, giving trainings, and blogging at blog.pieeatingninjas.be. In 2017, Pieter received a Microsoft MVP Windows Development Award for sharing his passion and expertise with the community.
 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.53.209