CROSS PLATFORM DEVELOPMENT XAMARIN INTRO
MOBILE LANDSCAPE  Desktop computers still exist, of course, and they remain vital for tasks that require keyboards and large screens: programming, writing, spread-sheeting, data tracking.  Although the mobile market has the potential for rapid change, currently two major phone and tablet platforms dominate:  The Apple family of iPhones and iPads, all of which run the iOS operating system.  The Android operating system, developed by Google based on the Linux kernel, which runs on a variety of phones and tablets.
MICROSOFT  There is also a third mobile development platform, which is not as popular as iOS and Android but involves a company with a strong history in the personal computer industry:  Microsoft’s Windows Phone and Windows 10 Mobile.  In recent years, these platforms have become a more compelling alternative as Microsoft has been merging the APIs of its mobile, tablet, and desktop platforms.  Both Windows 8.1 and Windows Phone 8.1 are based on a single API called theWindows Runtime (orWinRT), which is based on Microsoft .NET.This single API means that applications targeted for desktop machines, laptops, tablets, and phones can share very much of their code.  Even more compelling is the Universal Windows Platform (UWP), a version of the Windows Runtime that forms the basis for Windows 10 andWindows 10 Mobile. A single UWP application can target every form factor from the desktop to the phone.
PROBLEM ONE - USER INTERFACE  All three platforms incorporate similar ways of presenting the graphical user interface (GUI) and inter-action with the device through multi-touch, but there are many differences in detail.  Each platform has different ways to navigate around applications and pages, different conventions for the presentation of data, different ways to invoke and display menus, and even different approaches to touch.  Users become accustomed to interacting with applications on a particular platform and expect to leverage that knowledge with future applications as well. Each platform acquires its own associated culture, and these cultural conventions then influence developers.
PROBLEMTWO - DIFFERENT DEVELOPMENT ENVIRONMENTS  Programmers today are accustomed to working in a sophisticated integrated development environment (IDE). Such IDEs exist for all three platforms, but of course they are different:  For iOS development, Xcode on the Mac.  For Android development,Android Studio on a variety of platforms.  ForWindows development,Visual Studio on the PC.
PROBLEMTHREE - DIFFERENT PROGRAMMING INTERFACE  All three of these platforms are based on different operating systems with different APIs. In many cases, the three platforms all implement similar types of user-interface objects but with different names.  For example, all three platforms have something that lets the user toggle a Boolean value:  On the iPhone or iPad, it’s a “view” called UISwitch.  On Android devices, it’s a “widget” called Switch.  In the Windows Runtime API, it’s a “control” calledToggleSwitch.  The differences go far beyond the names into the programming interfaces themselves.
PROBLEM FOUR - DIFFERENT PROGRAMMING LANGUAGE  Developers have some flexibility in choosing a programming language for each of these three plat-forms, but, in general, each platform is very closely associated with a particular programming language:  Objective-C for the iPhone and iPad  Java for Android devices  C# forWindows  Objective-C, Java, and C# are cousins of sorts because they are all object-oriented descendants of C, but they have become rather distant cousins.
MULTIPLE PLATFORMS  For these reasons, a company that wants to target multiple platforms might very well employ three different programmer teams, each team skilled and specialized in a particular language and API.  This language problem is particularly nasty, but it’s the problem that is the most tempting to solve.  If you could use the same programming language for these three platforms, you could at least share some code between the platforms.This shared code likely wouldn’t be involved with the user interface because each platform has different APIs, but there might well be application code that doesn’t touch the user interface at all.  A single language for these three platforms would certainly be convenient. But what language would that be?
HISTORY  Soon after Microsoft’s announcement of .NET way back in June 2000, the company Ximian (founded by Miguel de Icaza and Nat Friedman) initiated an open-source project called Mono to create an alternative implementation of the C# compiler and the .NET Framework that could run on Linux.  A decade later, in 2011, the founders of Ximian (which had been acquired by Novell) founded Xamarin, which still contributes to the open-source version of Mono but which has also adapted Mono to form the basis of cross- platform mobile solutions.  The year 2014 saw some developments in C# and .NET that bode well for its future.An open-source version of the C# compiler, called the .NET Compiler Platform (formerly known by its code name “Roslyn”) has been published. And the .NET Foundation was announced to serve as a steward for open-source .NET technologies, in which Xamarin plays a major part.  In March 2016, Microsoft acquired Xamarin with the goal of bringing cross-platform mobile development to the wider Microsoft developer community. Xamarin.Forms is now freely available to all users ofVisual Studio.
SINGLE LANGUAGE XAMARIN PLATFORM  For the first three years of its existence, Xamarin focused mainly on compiler technologies and three basic sets of .NET libraries:  Xamarin.Mac, which has evolved from the MonoMac project.  Xamarin.iOS, which evolved from MonoTouch.  Xamarin.Android, which evolved from Mono for Android or (more informally) MonoDroid.
HOW IT WORKS…..
XAMARIN.FORMS  Xamarin.Forms supports five distinct application platforms:  iOS for programs that run on the iPhone, iPad, and iPodTouch.  Android for programs that run on Android phones and tablets.  The Universal Windows Platform (UWP) for applications that runs underWindows 10 orWindows 10 Mobile.  The Windows Runtime API of Windows 8.1.  The Windows Runtime API of Windows Phone 8.1.
HOW DOES IT WORK???  Example:  Suppose you need the user-interface object discussed earlier that allows the user to toggle a Boolean value.  When programming for Xamarin.Forms, this is called a Switch, and a class named Switch is implemented in the Xamarin.Forms.Core library.  In the individual renderers for the three platforms, this Switch is mapped to a  UISwitch on the iPhone  Switch on Android  ToggleSwitch onWindows Phone
ANOTHER….  Example:  Xamarin.Forms.Core also contains a class named Slider for displaying a horizontal bar that the user manipulates to choose a numeric value.  In the renderers in the platform-specific libraries, this is mapped to:  UISlider on the iPhone  SeekBar on Android  Slider on Windows Phone
SLIGHT DIFFERENCES  SixToolBarItem objects can be permitted, three identified as primary items with icons, and three as secondary items without icons.  On the iPhone these are rendered with UIBarButtonItem objects as the three icons and three buttons at the top of the page.  On the Android, the first three are rendered as items on an ActionBar, also at the top of the page.  OnWindows 10 Mobile, they’re realized as items on the CommandBar at the page’s bottom.  The Android ActionBar has a vertical ellipsis and the UniversalWindows Platform CommandBar has a horizontal ellipsis.  Tapping this ellipsis causes the secondary items to be displayed in a manner appropriate to these two platforms
HANDLING PLATFORM SPECIFICS  OnPlatform Tag  This is a technique that Xamarin.Forms uses to allow platform independent code.  So it’s used here as each platform has slight different image formats and size requirements associated with the icons.  Device Class can also determine device platform, enabling the code to modify font size, or run particular blocks of code based on the platform.
LIMITATIONS  Deeper Platform Specifics such as GPS Coordinates  Xamarin.Forms does not provide code for this, so you need to write platform specific code.  However….. Some classes provide support.  DependancyService Class provides a structured way to do this.  Define an Interface with the methods you need (such as, IGetMyLocation)  Implement that interface with a class in each platform projects.
OVERVIEW  Advantages:  Write one UI, Core maps elements across platforms  Write one set of code  Write Interfaces that can be used across all platforms  Disadvantages:  If you need platform specifics, may need additional code  Still need to write duplicate code

Mobile Dev - Cross Platform Intro - C# Xamarin

  • 1.
  • 2.
    MOBILE LANDSCAPE  Desktopcomputers still exist, of course, and they remain vital for tasks that require keyboards and large screens: programming, writing, spread-sheeting, data tracking.  Although the mobile market has the potential for rapid change, currently two major phone and tablet platforms dominate:  The Apple family of iPhones and iPads, all of which run the iOS operating system.  The Android operating system, developed by Google based on the Linux kernel, which runs on a variety of phones and tablets.
  • 3.
    MICROSOFT  There isalso a third mobile development platform, which is not as popular as iOS and Android but involves a company with a strong history in the personal computer industry:  Microsoft’s Windows Phone and Windows 10 Mobile.  In recent years, these platforms have become a more compelling alternative as Microsoft has been merging the APIs of its mobile, tablet, and desktop platforms.  Both Windows 8.1 and Windows Phone 8.1 are based on a single API called theWindows Runtime (orWinRT), which is based on Microsoft .NET.This single API means that applications targeted for desktop machines, laptops, tablets, and phones can share very much of their code.  Even more compelling is the Universal Windows Platform (UWP), a version of the Windows Runtime that forms the basis for Windows 10 andWindows 10 Mobile. A single UWP application can target every form factor from the desktop to the phone.
  • 4.
    PROBLEM ONE -USER INTERFACE  All three platforms incorporate similar ways of presenting the graphical user interface (GUI) and inter-action with the device through multi-touch, but there are many differences in detail.  Each platform has different ways to navigate around applications and pages, different conventions for the presentation of data, different ways to invoke and display menus, and even different approaches to touch.  Users become accustomed to interacting with applications on a particular platform and expect to leverage that knowledge with future applications as well. Each platform acquires its own associated culture, and these cultural conventions then influence developers.
  • 5.
    PROBLEMTWO - DIFFERENTDEVELOPMENT ENVIRONMENTS  Programmers today are accustomed to working in a sophisticated integrated development environment (IDE). Such IDEs exist for all three platforms, but of course they are different:  For iOS development, Xcode on the Mac.  For Android development,Android Studio on a variety of platforms.  ForWindows development,Visual Studio on the PC.
  • 6.
    PROBLEMTHREE - DIFFERENTPROGRAMMING INTERFACE  All three of these platforms are based on different operating systems with different APIs. In many cases, the three platforms all implement similar types of user-interface objects but with different names.  For example, all three platforms have something that lets the user toggle a Boolean value:  On the iPhone or iPad, it’s a “view” called UISwitch.  On Android devices, it’s a “widget” called Switch.  In the Windows Runtime API, it’s a “control” calledToggleSwitch.  The differences go far beyond the names into the programming interfaces themselves.
  • 7.
    PROBLEM FOUR -DIFFERENT PROGRAMMING LANGUAGE  Developers have some flexibility in choosing a programming language for each of these three plat-forms, but, in general, each platform is very closely associated with a particular programming language:  Objective-C for the iPhone and iPad  Java for Android devices  C# forWindows  Objective-C, Java, and C# are cousins of sorts because they are all object-oriented descendants of C, but they have become rather distant cousins.
  • 8.
    MULTIPLE PLATFORMS  Forthese reasons, a company that wants to target multiple platforms might very well employ three different programmer teams, each team skilled and specialized in a particular language and API.  This language problem is particularly nasty, but it’s the problem that is the most tempting to solve.  If you could use the same programming language for these three platforms, you could at least share some code between the platforms.This shared code likely wouldn’t be involved with the user interface because each platform has different APIs, but there might well be application code that doesn’t touch the user interface at all.  A single language for these three platforms would certainly be convenient. But what language would that be?
  • 9.
    HISTORY  Soon afterMicrosoft’s announcement of .NET way back in June 2000, the company Ximian (founded by Miguel de Icaza and Nat Friedman) initiated an open-source project called Mono to create an alternative implementation of the C# compiler and the .NET Framework that could run on Linux.  A decade later, in 2011, the founders of Ximian (which had been acquired by Novell) founded Xamarin, which still contributes to the open-source version of Mono but which has also adapted Mono to form the basis of cross- platform mobile solutions.  The year 2014 saw some developments in C# and .NET that bode well for its future.An open-source version of the C# compiler, called the .NET Compiler Platform (formerly known by its code name “Roslyn”) has been published. And the .NET Foundation was announced to serve as a steward for open-source .NET technologies, in which Xamarin plays a major part.  In March 2016, Microsoft acquired Xamarin with the goal of bringing cross-platform mobile development to the wider Microsoft developer community. Xamarin.Forms is now freely available to all users ofVisual Studio.
  • 10.
    SINGLE LANGUAGE XAMARINPLATFORM  For the first three years of its existence, Xamarin focused mainly on compiler technologies and three basic sets of .NET libraries:  Xamarin.Mac, which has evolved from the MonoMac project.  Xamarin.iOS, which evolved from MonoTouch.  Xamarin.Android, which evolved from Mono for Android or (more informally) MonoDroid.
  • 11.
  • 12.
    XAMARIN.FORMS  Xamarin.Forms supportsfive distinct application platforms:  iOS for programs that run on the iPhone, iPad, and iPodTouch.  Android for programs that run on Android phones and tablets.  The Universal Windows Platform (UWP) for applications that runs underWindows 10 orWindows 10 Mobile.  The Windows Runtime API of Windows 8.1.  The Windows Runtime API of Windows Phone 8.1.
  • 13.
    HOW DOES ITWORK???  Example:  Suppose you need the user-interface object discussed earlier that allows the user to toggle a Boolean value.  When programming for Xamarin.Forms, this is called a Switch, and a class named Switch is implemented in the Xamarin.Forms.Core library.  In the individual renderers for the three platforms, this Switch is mapped to a  UISwitch on the iPhone  Switch on Android  ToggleSwitch onWindows Phone
  • 14.
    ANOTHER….  Example:  Xamarin.Forms.Corealso contains a class named Slider for displaying a horizontal bar that the user manipulates to choose a numeric value.  In the renderers in the platform-specific libraries, this is mapped to:  UISlider on the iPhone  SeekBar on Android  Slider on Windows Phone
  • 15.
    SLIGHT DIFFERENCES  SixToolBarItemobjects can be permitted, three identified as primary items with icons, and three as secondary items without icons.  On the iPhone these are rendered with UIBarButtonItem objects as the three icons and three buttons at the top of the page.  On the Android, the first three are rendered as items on an ActionBar, also at the top of the page.  OnWindows 10 Mobile, they’re realized as items on the CommandBar at the page’s bottom.  The Android ActionBar has a vertical ellipsis and the UniversalWindows Platform CommandBar has a horizontal ellipsis.  Tapping this ellipsis causes the secondary items to be displayed in a manner appropriate to these two platforms
  • 16.
    HANDLING PLATFORM SPECIFICS OnPlatform Tag  This is a technique that Xamarin.Forms uses to allow platform independent code.  So it’s used here as each platform has slight different image formats and size requirements associated with the icons.  Device Class can also determine device platform, enabling the code to modify font size, or run particular blocks of code based on the platform.
  • 17.
    LIMITATIONS  Deeper PlatformSpecifics such as GPS Coordinates  Xamarin.Forms does not provide code for this, so you need to write platform specific code.  However….. Some classes provide support.  DependancyService Class provides a structured way to do this.  Define an Interface with the methods you need (such as, IGetMyLocation)  Implement that interface with a class in each platform projects.
  • 18.
    OVERVIEW  Advantages:  Writeone UI, Core maps elements across platforms  Write one set of code  Write Interfaces that can be used across all platforms  Disadvantages:  If you need platform specifics, may need additional code  Still need to write duplicate code