• This repository has been archived on 03/Nov/2020
  • Stars
    star
    725
  • Rank 62,504 (Top 2 %)
  • Language
    C#
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Code samples for "Creating Mobile Apps with Xamarin.Forms"

xamarin-forms-book-samples

This repo has been archived. The samples are no longer current, or updated. However, they still make a great learning resource.

Sample code for the book Creating Mobile Apps with Xamarin.Forms. The book can be downloaded from https://docs.microsoft.com/xamarin/xamarin-forms/creating-mobile-apps-xamarin-forms/.

A handful of F# samples in this repo are available via the Microsoft code sample browser, but there are over 1,000 projects and the majority of them are only available by cloning the repo.

Notes

Loading the NuGet Packages

The Xamarin.Forms NuGet packages are not part of these projects. They must be downloaded for each project.

To avoid hassles, download the NuGet packages for the solutions in the Libraries directory first. You'll want to load each library solutions into Visual Studio, right-click the solution name in the Solution List and select Manage NuGet Packages for Solution. A notice might appear at the top of the Manage NuGet Packages dialog that says "Some NuGet packages are missing from this solution. Click to restore from you online package sources." If so, click the Restore button and then the Close button. Build the library.

Do the same thing with the other library solutions in the Libraries directory.

You can then load any of the application projects. For each project, again right-click the solution name, select Manage NuGet Packages for Solution and go through the same process.

The Branches

The original-code-from-book branch of this repository contains the code as it appeared in the Creating Mobile Apps with Xamarin.Forms book. The only change is that the projects have been updated to the latest Xamarin.Forms version.

The projects in the master branch reflect changes in C# and Xamarin.Forms since the writing of the book. These changes are:

  • In code files, the deprecated Device.OnPlatform calls have been replaced with logic using the Device.RuntimePlatform property.
  • In XAML files, deprecated properties of the OnPlatform class have been replaced with On objects.
  • The use of the deprecated Device.TargetPlatform property have been replaced with Device.RuntimePlatform.
  • Calls to the deprecated VisualElement.GetSizeRequest method have been replaced with calls to Measure.
  • Overrides of the deprecated VisualElement.OnSizeRequest method have been replaced with overrides of OnMeasure.
  • Calls to and implementations of the deprecated TypeConverter.ConvertFrom method have been replaced with ConvertFromInvariantString.
  • The NamedColor class is now based on the Color structure rather than its own static fields.
  • The Android projects have been upgraded to use AppCompat and Material Design. This is consistent with recent Xamarin.Forms project templates.
  • The blank bitmaps in the Assets folder of the UWP projects have been replaced with Xamagon images.
  • Event firing uses the null-conditional operator (?.) and the Invoke method.

The Projects

These solutions contain three application projects:

  • iOS: iPhone and iPads
  • Droid: Android phones and tablets
  • UWP: The Universal Windows Platform, targeting Windows 10 tablets and desktop computers, and Windows 10 Mobile

The original-code-from-book branch also contains the following two applicatin projects:

  • Windows: Windows 8.1 tablets and desktop computers using the Windows Runtime API
  • WinPhone: Windows Phone 8.1 devices using the Windows Phone API.

You can deploy the UWP project to devices or emulators. However, you must select the correct platform for the deployment target. You generally do this by selecting a platform for the solution in the Solution Platform dropdown on the Standard toolbar. Or, you can invoke the Configuration Manager dialog form the Build | Configuration Manager menu item, and select an item from the Active solution platform dropdown at the top right.

The six possible Solution Platform options are listed below. Each is associated with a particular platform for the UWP project. This platform refers to processor architectures:

  • Any CPU: UWP platform is x86
  • ARM: UWP platform is ARM
  • iPhone: UWP platform is x86
  • iPhone Simulator: UWP platform is x86
  • x86: UWP platform is x86
  • x64: UWP platform is x64

These reflect the only three possibilities for the UWP project. As you can see, x86 (32-bit Intel architecture) is considered to be the default.

Currently, you can deploy the UWP project in several different ways based on a selection in the dropdown on the Standard toolbar.

  • Select Local Machine to deploy directly to the Windows 10 desktop. The UWP platform must be x86 or x64.

  • Select Simulator to deploy to a Windows 10 simulator window. The UWP platform must be x86.

  • Select one of the items beginning with the words Mobile Emulator 10.0 to deploy to a Windows 10 Mobile emulator. The UWP platform must be x86.

  • Select Device to deploy to a Windows 10 Mobile device. The UWP platform must be ARM.

Version upgrades

As of August 12, 2016, all sample code has been upgraded to Xamarin.Forms version 2.3.1.114.

As of November 23, 2016, all sample code has been upgraded to Xamarin.Forms version 2.3.3.168.

As of May 2, 2017, all sample code has been upgraded to Xamarin.Forms version 2.3.4.231.

As of November 3, 2017, all sample code has been upgraded to Xamarin.Forms version 2.4.0.38779.

As of April 13, 2018, all sample code has been upgraded to Xamarin.Forms version 2.5.0.280555.

Removing Obsolete Project Types

As of April 17, 2018, all Windows (Windows 8.1) and WinPhone (Windows Phone 8.1) projects have been removed from the samples. The Windows and WinPhone projects can still be found in the original-code-from-book branch.

.NET Standard

As of May 3, 2018, all solutions in the master branch have been converted from using Portable Class Libraries (PCL) to .NET Standard 2.0 libraries. In addition, the application projects have been converted to a new format using PackageReference. This conversion makes the solutions much closer to what Visual Studio 2017 creates today as a new Xamarin.Forms solution.

The new features of the .csproj files simplify the references to NuGet libraries. There are no longer any packages.config files in any of the projects, and the references to NuGet libraries in the .csproj files are greatly reduced in bulk. The .NET Standard Library project no longer has an AssemblyInfo.cs file, and the UWP project no longer has any project.json or project.lock.json files.

The solutions using PCL's have been archived in the archive-pcl branch. That branch will not be updated.

It is recommended that all new Xamarin.Forms projects be created with Visual Studio 2017, and that Visual Studio 2017 also be used for existing Xamarin.Forms projects.

As of May 4, 2018, all solutions in the master branch have been upgraded to Xamarin.Forms 2.5.1.527436.

As of May 9, 2018, all solutions in the master branch have been upgraded to Xamarin.Forms 3.0.0.446417.

As of July 17, 2018, all solutions in the master branch have been upgraded to Xamarin.Forms 3.1.0.637273.

As of September 4, 2018, all iOS projects in the master branch have been restricted to 64-bit architectures.

As of September 10, 2018, the deprecated AndroidUseLastestPlatformSdk element has been removed from all Android project files in the master branch.

As of September 14, 2018, another PropertyGroup has been added to the .NET Standard library with a DebugType element. This is required for setting breakpoints when deploying to the UWP.

More Repositories

1

Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
C#
5,637
star
2

xamarin-forms-samples

Sample apps built using the Xamarin.Forms framework
C#
4,304
star
3

xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
C#
2,441
star
4

monodroid-samples

A collection of Xamarin.Android sample projects.
C#
2,197
star
5

XamarinComponents

Plugins for Xamarin
C#
1,990
star
6

ios-samples

Xamarin.iOS sample apps
C#
1,593
star
7

XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
C#
1,588
star
8

Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
C#
1,523
star
9

mobile-samples

C#
1,460
star
10

XobotOS

XobotOS - Android ported to C#
Java
1,246
star
11

docs-archive

Xamarin docs archive
Java
565
star
12

Xamarin.Auth

Xamarin.Auth
C#
544
star
13

urho

Code to integrate with the Urho3D engine
C#
463
star
14

app-crm

C#
384
star
15

urho-samples

Samples for the Urho bindings
C#
383
star
16

Sport

C#
358
star
17

Monkey.BluetoothLE

BluetoothLE abstraction for use with Xamarin projects, including Xamarin.Forms.
C#
348
star
18

mac-samples

Sample programs showing how to use Xamarin.Mac on OSX.
C#
321
star
19

GooglePlayServicesComponents

C#
307
star
20

WebSharp

Support for running C# on the web browser.
C#
302
star
21

mqtt

Minimalist and intuitive MQTT broker and client written entirely in C#
C#
297
star
22

dev-days-labs

C#
295
star
23

KimonoDesigner

Paint application using Xamarin.Mac and SkiaSharp
C#
260
star
24

SignaturePad

C#
246
star
25

GoogleApisForiOSComponents

C#
224
star
26

prebuilt-apps

Complete, prebuilt apps for you to customize and deploy.
C#
217
star
27

xamarin-forms-book-preview-2

Sample code for the 2nd Preview Edition of "Creating Mobile Apps with Xamarin.Forms"
C#
209
star
28

flex

Flex is a flexible box layout system written in C, designed to be easy to consume from other languages
C
192
star
29

Workbooks

C#
188
star
30

AndroidX

AndroidX bindings for .NET for Android
C#
168
star
31

binding-tools-for-swift

C#
154
star
32

AndroidSupportComponents

Xamarin bindings for Android Support libraries - For AndroidX see https://github.com/xamarin/AndroidX
C#
145
star
33

XamarinStripe

Stripe.com .NET bindings
C#
134
star
34

Xamarin.Social

Xamarin.Social
C#
125
star
35

AngryNinjas

Angry Ninjas Cocos2D/XNA Sample
C#
120
star
36

customer-success-samples

Xamarin Customer Success
104
star
37

KinderChat

Secure Texting for Children
C#
98
star
38

VervetaCRM

Publicly available CRM demonstration app.
C#
97
star
39

ExposureNotification.Sample

A sample cross-platform mobile app and server for exposure notifications.
C#
94
star
40

mini-hacks

Complete four mini-hacks during Evolve and get a prize.
C#
89
star
41

PortableRazor

A lightweight implementation of ASP.NET MVC APIs for mobile devices.
C#
89
star
42

FacebookComponents

C#
86
star
43

Seminars

Sample code used in the Xamarin Seminars
C#
68
star
44

amazon

Library for accessing Amazon web services from mobile apps
C#
62
star
45

xamarin-forms-book-preview

Sample code for the Preview Edition of "Creating Mobile Apps with Xamarin.Forms"
C#
61
star
46

mac-ios-samples

Samples targeting both iOS and OSX that share code.
C#
56
star
47

XamarinAzureChallenge

Create an iOS/Android app using Xamarin.Forms and connect it to a serverless Azure Function
C#
56
star
48

Touch.Unit

NUnitLite based runner for unit testing .NET code under iOS
C#
50
star
49

google-apis

Google API bindings for Xamarin.
C#
47
star
50

xamarin-evolve-2014

Slides, Demos and Training samples for Evolve 2014 from Xamarin University
C#
45
star
51

mobcat

43
star
52

Rivets

A C# implementation of App Links, functionally, a port of Bolts
C#
43
star
53

app-xamarintv

Xamarin.Forms app demonstrating the dual-screen device capability for neo and duo devices
C#
42
star
54

Xamarin.Forms.CarouselView

C#
41
star
55

Xamarin.Forms.GraphQL

C#
41
star
56

evolve-quest

Evolve Quest is an iBeacon based scavenger hunt that attendees enjoyed at Evolve 2014
C#
35
star
57

android-activity-controller

C#
35
star
58

xamarin-iot-samples

Samples for Xamarin IoT
C#
35
star
59

monotouch-element-pack

A place to host various MonoTouch.Dialog.Elements that users can use.
C#
35
star
60

Xamarin.Forms-api-docs

Xamarin.Forms API documentation in ECMA XML format
PowerShell
34
star
61

PortableRazorStarterKit

A starter kit for PortableRazor.
JavaScript
34
star
62

Xamarin.Legacy.Sdk

Starting from a .NET 6 project, adds the ability to target legacy Xamarin target frameworks such as monoandroid11.0 or xamarin.ios10. *Not fully supported*
34
star
63

SalesforceSDK

Salesforce SDK component
C#
31
star
64

apple-api-docs

Xamarin.iOS & Xamarin.Mac API documentation in ECMA XML format
F#
27
star
65

sketches

Xamarin Sample Sketches
26
star
66

benchmarker

A simple benchmarking and comparison tool
C#
26
star
67

Xamarin.MacDev

Support libraries for xamarin-macios
C#
25
star
68

mirepoix

A small collection of utility APIs including command line argument splitting and quoting, file system globbing, cross platform process execution, and console output redirection handling.
C#
25
star
69

Xamarin.PropertyEditing

C#
24
star
70

xamarinu-connect2016

C#
23
star
71

app-customers

A simple demo app with three screens: a list screen, a read-only detail screen, and an editable detail screen.
C#
23
star
72

xunit

xUnit
C#
22
star
73

MyCompany

C#
22
star
74

jar2xml

Java Archive API extraction tool
Java
19
star
75

android-api-docs

Android API documentation
PowerShell
19
star
76

demo-xamarincrm

C#
19
star
77

Urho3D

Clone of the Urho3D repository
C++
19
star
78

XamarinAndroidXMigration

Build tasks and tools to support Xamarin.Android AndroidX migration
C#
18
star
79

xamarin-evolution

Maintains proposals for changes to the Xamarin SDKs (Android, iOS, Forms, Components, Urho, Skia)
18
star
80

dropbox-sync-component

C#
18
star
81

vs-mono-debugger-sample

Sample showing how to use the Visual Studio Mono Debugger for your own Mono-based project types
C#
17
star
82

DocWriter

Desktop Editor for the ECMA XML Documentation
C#
16
star
83

evolve-presentation-template

Evolve 2016 Presentation Templates
HTML
15
star
84

SaveTheDate

C#
14
star
85

xamarin-windows

Provides reusable MSBuild tasks and sample Visual Studio tooling for building and debugging Mono AOT compiled binaries
C#
14
star
86

fsharpbinding

F# binding for MonoDevelop (updated to support Xamarin Studio)
F#
14
star
87

Windows.Injector

Allows injecting .NET code into a remote process in Windows
C++
13
star
88

web-tests

C#
12
star
89

md-xamarin-fsharp-addins

F# magic
F#
11
star
90

fsharp-iOS-designer

iOS designer integration for F#
F#
11
star
91

moq

The most popular and friendly mocking library for .NET and Xamarin
C#
9
star
92

sales-uitest-extensions

Extension methods for UITest
C#
7
star
93

component-template

A sample template that you can use as a guide to create your own components.
Ruby
7
star
94

xamarin-android-binutils

LLVM toolchain for Xamarin.Android
C++
7
star
95

evolve-2014-presentation-template

Evolve 2014 Presentation Template
7
star
96

emscripten-test

C
6
star
97

Gendarme.Rules.Xamarin

Gendarme static analysis rules for Xamarin.
C#
6
star
98

NuGetizer3000

C#
6
star
99

Wikitude

C#
6
star
100

release-notes-archive

Xamarin release notes from 2018 and earlier
HTML
6
star