Developing Cross-Platform Apps with C# using Xamarin
C# is one of the most popular development languages in the world but we write the majority of mobile apps in Java, Swift or Objective-C. While it was originally possible to build .NET apps running on Windows-based devices only, the game has changed. Dramatically.
Using Xamarin, we can now write apps, which run on Android and iOS devices natively using C#. This way, C# allows us to target billions of extra devices using the language we all love. The experiences, which users get from Xamarin-base apps, are fully native: the apps aren't web-based, trimmed-down versions of the apps. Instead, they offer the full functionality of the platform they target.
The impact in terms of re-using code is huge. We can build architecture with this cross-platform functionality in mind and construct it so that a lot (or maybe we should say: most) of our code can be re-used in Windows Phone, iOS and Android apps.
In this course, you'll learn about the Xamarin environment. You'll learn about cross-platform development, Xamarin.Android and Xamarin.iOS. All this becomes possible using the knowledge you already have: C#!
Students should have experience developing applications or websites using C#; the course assumes you are familiar with the C# language. XAML knowledge is a plus but is not required.
Chapter 1: C# Review
To start we review some of the key features of the C# language that you will need to understand and exploit when developing effective Xamarin apps.
- Value and Reference Types under the hood
- Classes, Encapsulation and Properties
- Inheritance and Polymorphism
- Interfaces and Decoupling
- Dependency Injection
- Inversion of Control
- Anonymous Delegates and Lambdas
- Tasks and async
- Useful Design Patterns
Chapter 2: Xamarin Introduction
Next we set the scene by introducing Xamarin and discuss where it fits in and how it can be best used. We look at some of the mobile development challenges and then begin to take a look at the mighty tool itself.
- What is Xamarin
- Bit of History
- Benefits and Disadvantages of using Xamarin
- Mobile Development Challenges
- Where does it fit in?
- How does it work?
- What you need to get started
- Getting started with Xamarin Studio
Chapter 3: Getting Started with Xamarin.android
In Chapter 3 we are straight into the fundamentals of android app development and look at creating projects, setting correct API versions and working with resources such as layouts and images. After reviewing android App architecture we then create our first activity and soon create a multi activity app with Intents. By the end you have your first android app.
- android Projects
- API Versions
- Resources and Images
- App Architecture
- Creating Activities
- Accessing Views
- Working with Intents
- Launching Activities
- Passing data between activities
- Working with an activities lifecycle
Chapter 4: Designing your android UI with Layouts
Laying out your activities is an essential part of designing an app. That's why we take some time to explore the various options available that enable you to create an adaptable layout. We also take a look at some of the widely used UI views available out of the box.
- Creating the UI with the Designer
- Designing Layouts and working with
- Grid layouts
- Working with some of the built in views including
- Date and time picker
- Standard Views
Chapter 5: Lists, Tabs and Fragments in android
Displaying lists of information is an essential part of any app so we spend some time exploring how we can present standard and custom lists of data to users. We also look at how we can present a Tabbed interface and introduce the concept of reusable fragments.
- ListViews and ListAdapters
- Custom ListAdapters
- Built in and Custom Row Layouts
- Working with Fragments
- Using fragments declaratively and programmatically
- The FragmentManager
- Fragment Lifecycle
- State Management
- Tabs and the Action Bar
Chapter 6: Additional android Issues
To finish off android development we look at some additional issues that you need to be aware off.
- Activity Lifecycle
- State Management
- Rotation and managing alternate layouts
- Drawables and resolution
Chapter 7: Cross Platform Code Sharing
The big win with Xamarin is code reuse across platforms. The more reuse the greater the benefit. We will look at how this can be achieved.
- Why Code Share
- Code sharing Options
- Shared Projects
- Portable Class Libraries
- Ramping up code reuse across platforms
- Cross Platform Data Access
- Abstracting device specificity
- Dependency Injection
- Inversion of Control Containers
- MVVM Pattern
- MVVM Light
Chapter 8: Getting Started With iOS Development in Xamarin
In this chapter you will use the same C# language to write an iOS app. We will find out about designing our app with a storyboard and then hook it up to code in the form of a View Controller. In no time we are creating multi scene applications and are segueing between them.
- iOS Development in Xamarin
- Solutions, Projects and Files
- Intro to Storyboards, Scenes and Segues
- MVC and View Controllers
- Linking Scenes to View Controllers
- Working with Multiple View Controllers
- Modal Display
- Navigation Controllers
- Transferring Data between Scenes
- Loading Storyboards from Code
Chapter 9: Designing an iOS Layout
In Chapter 8 we look at how we can design a UI to respond to changes in container size using a combination of Auto Layout and Size Classes. We will also explore some of the UI controls.
- Xamarin iOS Designer Intro
- Designing a View
- Using Auto Layout
- Working with Constraints
- Understanding and Exploiting Size Classes
- iOS UI Controls
- Unwind Segues
Chapter 10: Working with Table Views
The workhorse of any app is the table view. We use it to display data and even to layout our data entry forms. In this chapter we will explore the table view. We will also look at a related view called the Collection view.
- Table Views
- Types of Table View
- Building a Table View
- Static Table Views
- Dynamic Table Views
- Table View Controllers
- Table View Cells
- Headers and Footers
- Editing Cells
- Collection Views
Chapter 11: Controlling iOS Navigation and Storage
We finish off our look as iOS development in Xamarin by covering iOS navigation and looking at how we can store basic data.
- Manual Storyboards
- Navigation Controllers
- Tab Bar Controllers
- Modal View Controllers
- Split View Controllers
- Settings and plists
- Working with files
- User Defaults Database
Chapter 12: App Deployment for android and iOS
So your app is complete and ready to be deployed. So how do you do that? We will look at the issues involved in deploying your app to the relevant app stores.
- Preparing and app for deployment
- Deploying to the app store
Chapter 13: Xamarin.Forms
Having spent most of the course writing separate apps for android and iOS we now look to Xamarin forms to unify our development process. 'Write once run everywhere' is the pitch but can we really write one set of UI code and run it on android, iOS and Windows phone. In this chapter we will find out.
- What are Xamarin Forms
- Getting started with…
- How it works
- Basic elements
- Sizing and Positioning
- Hooking up to Code
Chapter 14: Forms, ListViews and Data Binding with Xamarin.Forms
We look a little more closely at writing forms and lists and introduce data binding with XAML.
- Data Binding Overview
- Page Binding
- Change Notification
- Field Binding
- Field to Field Binding
- Displaying Lists with the ListView
- Making life easier with Resources and Styles