More Information
Learn
  • Set up Xamarin.Forms to build native apps with code-sharing capabilities
  • Understand the core aspects of developing a mobile app, such as its layout, UX, and rendering
  • Use custom renderers to gain platform-specific access
  • Discover how to create custom layouts for your apps with Xamarin.Forms Shell
  • Use Azure SignalR to implement serverless services in your Xamarin apps
  • Create an augmented reality (AR) game for Android and iOS using ARCore and ARKit, respectively
  • Build and train machine learning models using CoreML, TensorFlow, and Azure Cognitive Services
About

Xamarin.Forms is a lightweight cross-platform development toolkit for building apps with a rich user interface. Improved and updated to cover the latest features of Xamarin.Forms, this second edition covers CollectionView and Shell, along with interesting concepts such as augmented reality (AR) and machine learning.

Starting with an introduction to Xamarin and how it works, this book shares tips for choosing the type of development environment you should strive for when planning cross-platform mobile apps. You’ll build your first Xamarin.Forms app and learn how to use Shell to implement the app architecture. The book gradually increases the level of complexity of the projects, guiding you through creating apps ranging from a location tracker and weather map to an AR game and face recognition. As you advance, the book will take you through modern mobile development frameworks such as SQLite, .NET Core Mono, ARKit, and ARCore. You’ll be able to customize your apps for both Android and iOS platforms to achieve native-like performance and speed. The book is filled with engaging examples, so you can grasp essential concepts by writing code instead of reading through endless theory.

By the end of this book, you’ll be ready to develop your own native apps with Xamarin.Forms and its associated technologies, such as .NET Core, Visual Studio 2019, and C#.

Features
  • Develop mobile apps, AR games, and chatbots of varying complexity with the help of real-world examples
  • Explore the important features of Xamarin.Forms 4 such as Shell, CollectionView, and CarouselView
  • Get to grips with advanced concepts such as AR and VR and machine learning for mobile development
Page Count 504
Course Length 15 hours 7 minutes
ISBN 9781839210051
Date Of Publication 19 Jun 2020
Technical requirements
An overview of the project
Beginning the project
Setting up the project
Creating the new project
Examining the files
DoToo
DoToo.Android
DoToo.iOS
DoToo.UWP
Updating the Xamarin.Forms packages
Removing the MainPage file
Creating a repository and a TodoItem model
Defining a to-do list item
Creating a repository and its interface
Connecting SQLite to persist data
Adding the SQLite NuGet package
Updating the TodoItem class
Creating a connection to the SQLite database
Implementing the GetItems(), AddItems(), and UpdateItems() methods
Using MVVM – creating views and ViewModel
Defining a ViewModel base class
Introducing PropertyChanged.Fody
Creating the MainViewModel
Creating the TodoItemViewModel
Creating the ItemViewModel class
Creating the MainView view
Creating the ItemView view
Wiring up a dependency injection through Autofac
Adding a reference to Autofac
Creating the resolver
Creating the bootstrapper
Adding a bootstrapper on iOS
Adding a bootstrapper in Android
Adding a bootstrapper in UWP
Making the app run
Adding data bindings
Navigating from MainView to ItemView to add a new item
Adding new items to the list
Binding ListView in MainView
Creating a ValueConverter object for the item status
Using ValueConverter
Navigating to an item using a command
Marking an item as complete using a command
Creating the filter toggle function using a command
Laying out the contents
Setting an application-wide background color
Laying out the MainView and ListView items
The filter button
Touching up ListView
Summary
Technical requirements
Project overview
Getting started
Building the news app
Setting up the project
Creating the new project
Updating Xamarin.Forms packages
Creating the structure of the app
Creating the ViewModel base class
Recapping on Quick PropertyChanged.Fody
Implementing INotifyPropertyChanged
Adding a reference to PropertyChanged.Fody
Creating a FodyWeaver file
Creating the HeadlinesViewModel class
Creating the HeadlinesView
Creating the ArticleItem
Creating the ArticleView
Creating the AboutView
Wiring up dependency injection through Autofac
Adding a reference to Autofac
Creating the resolver
Creating the bootstrapper
Initializing the bootstrapper
Downloading and configuring Font Awesome
Downloading Font Awesome
Adding Font Awesome to Info.plist on iOS
Adding the font to a static resource
Defining some icons in the resource dictionary
Defining the shell
Creating the MainShell file
Defining the basic structure
Adding the MainShell type to the container
Making the app run
Creating the news service
Obtaining an API key
Creating the models
Creating a service class
Creating the NewsScope enum
Enabling C# 8
Creating the NewsService class
Wiring up the NewsService class
Extending the HeadlinesViewModel class
Extending the HeadlinesView
Extending the ContentView of the ArticleItem
Adding to the bootstrapper
Adding a ContentTemplate attribute
Handling navigation
Creating the navigation service
Creating the INavigation interface
Implementing the INavigation interface using Shell
Adding the INavigation interface to the ViewModel class
Navigating using routes
Finalizing the ItemSelected command
Extending the ArticleView to receive query data
Extending the ArticleView with a WebView
Registering the route
Summary
Technical requirements
Essential theory
An overview of the project
Setting up the project
Creating the project
Updating the Xamarin.Forms NuGet packages
Setting the Android target framework version to 9.0
Adding the camera permission to Android
Adding a camera usage description for iOS
Defining the user interface
Creating the ARView control
Modifying the MainPage
Adding UrhoSharp
Installing the UrhoSharp NuGet package for iOS and the .NET Standard project
Installing the UrhoSharp.ARCore NuGet package for Android
Adding the Android life cycle events
Defining the PlaneNode class
Adding custom renderers for the ARView control
For iOS
For Android
Creating the game
Adding the shared abstract Game class
InitializeAR
CreateSubPlane
UpdateSubPlane
FindNodeByPlaneId
Adding platform-specific classes
Adding the iOS-specific class
Adding the Android-specific class
Writing the ARKit-specific code
Defining the ARKitComponent
Writing handlers for adding and updating anchors
SetPositionAndRotation
UpdateOrAddPlaneNode
OnAddAnchor
OnUpdateAnchors
Writing a handler for removing anchors
OnRemoveAnchors
Initializing ARKit
Writing the ARCore-specific code
Defining the ARCoreComponent
SetPositionAndRotation
Writing a handler for ARFrame updates
Initializing ARCore
OnConfigRequested
InitializeAR
Writing the game
Adding a camera
Configuring a renderer
Adding lights
Implementing the game startup
Adding boxes
AddBox()
OnUpdate()
Making boxes rotate
Creating the rotate component
Assigning the Rotator component
Adding a box hit-test
Adding a death animation
DetermineHit()
OnTouchBegin()
Wiring up input
Updating statistics
Defining a statistics class
Sending updates via MessagingCenter
Wiring up events
Updating the GUI
Subscribing to the updates in the MainPage class
Summary

Authors

Daniel Hindrikes

Daniel Hindrikes is a developer and architect with a passion for developing mobile apps powered by the cloud. Daniel fell in love with Xamarin in the early days of Xamarin when he realized that he could use C# even for iOS and Android apps, and that he could share code with the Windows apps he was also building. But Daniel started to build mobile apps long before that, working on Android apps with Java and even Java ME apps (a long, long time ago). Daniel enjoys sharing his knowledge and can be found speaking at conferences, blogging, or recording the podcast, The Code Behind. Daniel works at the company tretton37 in Sweden and has experience working with both local and global customers.

Johan Karlsson

Johan Karlsson has been working with Xamarin since the days of MonoTouch and Mono for Android, and it all started with writing a game. He is a full-stack developer, currently focusing on mobile applications using Xamarin, but has in the past worked a lot with ASP.NET MVC, Visual Basic.NET (not proud), and C# in general. Also, he's created a whole bunch of databases in SQL Server over the years. Johan works at tretton37 in Sweden and has about 20 years' experience in the trade of assembling ones and zeros.