Index

James Montemagno
Xamarin 101 serie

I wish I had started here.

Xamarin Tutorial for Beginners – Build iOS & Android Apps with C#, Visual Studio, and Xamarin.Forms

Video

  • 00:00 – Intro & What is .NET, C#, Xamarin
  • 04:20 – Creating First Project in Visual Studio
  • 08:45 – What’s in the solution (.NET Standard, iOS, Android)
  • 12:40 – Exploring iOS and Android project setup 7 shared code
  • 14:15 – MVVM (Model-View-ViewModel)
  • 15:30 – Exploring XAML (App, AppShell, and Pages)
  • 21:00 – Deploying to Android, Debugging, & XAML Hot Reload
  • 28:20 – Deploying to iOS with Hot Restart
  • 35:45 – Wrap-up

Configuring & Optimizing Xamarin Projects – Smaller, Faster, Better Apps

Video

  • 00:00 – Welcome & Intro
  • 01:45 – Project Walkthrough
  • 02:45 – Android Manifest
  • 05:00 – Android Project Settings – Debug Settings
  • 09:10 – Android Project Settings – Release Settings
  • 12:25 – Android Compile & Target Settings
  • 17:30 – Compiled Final Android Manifest
  • 19:10 – iOS Info.plist & Entitlements.plist Location
  • 20:00 – iOS Project Settings – Debug Settings
  • 22:10 – iOS Project Settings – Release Settings
  • 24:20 – Additional iOS Project Settings
  • 25:30 – iOS Info.plist & Entitlements.plist Overview
  • 31:30 – Wrap-up

Managing & Updating Xamarin NuGet Packages Efficiently

Video

  • 00:00 – Welcome – Let’s upgrade our NuGets
  • 01:30 – What is a NuGet package?
  • 03:30 – Exploring Dependencies
  • 05:30 – Manage & Update NuGet Packages for Solution
  • 09:30 – Consolidate NuGet Package Updates
  • 10:10 – Exploring NuGet
  • 13:10 – NuGet Package Explorer
  • 15:40 – Modifying Package References in the csproj
  • 18:00 – Wrap-up & Xamarin.Plugins Repo

Preparing a Xamarin.Forms Shell App for Development

Video

Xamarin.Forms XAML 101 + Hello World! (& .NET MAUI)

Video

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/

MVVM 101 – Model-View-ViewModel Architecture for Xamarin.Forms & .NET MAUI (also WPF, UWP, & More)

Video

  • 00:00 – Introduction
  • 01:30 – What is MVVM?
  • 05:30 – Using Data Binding and INotifyPropertyChanged
  • 14:10 – What is ICommand
  • 17:30 – Using Commands, not Click Handlers
  • 20:30 – Our First View Model
  • 25:00 – Wrap-up

Binding modes

  • OneWay: This is used when ViewModel updates a value. It should be reflected on the View
  • OneWayToSource: This is used when the View changes a value. This value change should be pushed to the ViewModel.
  • TwoWay: The data-flow is bidirectionnal
  • OneTime: Data synchronization only occurs once the binding context has been bound and the data has been propagated from the ViewModel to the View.
In ViewModel
public partial class XXViewModel : ContentPage // extends INotifyPropertyChanged
{

  private uint count = 0;

  private string countDisplay = string.Empty;
  public string CountDisplay
  {
	  get => countDisplay;
	  set
	  {
		  if (value == countDisplay)
		  	return;
		  countDisplay = value;
		  OnPropertyChanged(); // thanks to [CallerMemberName], can get rid of nameof(CountDisplay)
	  }
  }

  public CoffeeEquipmentPage()
  {
	  InitializeComponent();
	  BindingContext = this;
  }

  private void ButtonClick_Clicked(object sender, System.EventArgs e)
  {
	  count++;
	  CountDisplay = $"{count.ToString()} times";
  }

}
In View (XAML)
Button Text="{Binding CountDisplay}" Clicked="ButtonClick_Clicked" />

Commands

In ViewModel
private void onIncrease()
{
  count++;
  CountDisplay = $"{count.ToString()} times";
}
In Model
<Button Text="{Binding CountDisplay}" Command="{Binding IncreaseCount}" />

Separate ViewModel file

In Model
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:viewmodels="clr-namespace:MyCoffeeApp.ViewModels"
    x:DataType="viewmodels:CoffeeEquipmentViewModel"
    x:Class="MyCoffeeApp.Views.CoffeeEquipmentPage"
    >
  <ContentPage.BindingContext>
    <viewmodels:CoffeeEquipmentViewModel />
  </ContentPage.BindingContext>
    <ContentPage.Content>
      <Button Text="{Binding CountDisplay}" Command="{Binding IncreaseCount}" />
    </ContentPage.Content>
</ContentPage>
In ViewModel
using Xamarin.Forms;
using System.Windows.Input;

namespace MyCoffeeApp.ViewModels
{
	public class CoffeeEquipmentViewModel : BindableObject
	{
		private uint count = 0;

		private string countDisplay = "Click me to start";

		public string CountDisplay
		{
			get => countDisplay;
			set
			{
				if (value == countDisplay)
					return;
				countDisplay = value;
				OnPropertyChanged(); // thanks to [CallerMemberName], can get rid of nameof(CountDisplay)
			}
		}

		public ICommand IncreaseCount { get; }

		public CoffeeEquipmentViewModel()
		{
			IncreaseCount = new Command(onIncrease);
		}

		private void onIncrease()
		{
			count++;
			CountDisplay = $"{count.ToString()} times";
		}
	}
}

Better MVVM with MVVM Helpers (or Xamarin Community Toolkit

Video

  • 00:00 – Introduction
  • 01:30 – MVVM Helpers – What & Install NuGet
  • 05:00 – Upgrading with ObservableObject & BaseViewModel
  • 10:30 – AsyncCommand
  • 12:00 – ObservableRangeCollection
  • 17:00 – Xamarin Community Toolkit

MVVM Helpers – What & Install NuGet

  • Why? remove dependency to Xamarin (testing, reusability, etc.)
  • Vanilla-oriented MVVM framework (alternative to MVVMCross, Prism, etc.
System.Windows.Input.Command >>> MvvmHelpers.Commands.Command
MvvmHelpers.Commands.AsyncCommand
MvvmHelpers.ObservableObject
private string countDisplay = "Click me to start";
public string CountDisplay
{
	get => countDisplay;
	set => SetProperty(ref countDisplay, value);
}
System.Collections.ObjectModel.ObservableCollection >>> MvvmHelpers.ObservableRangeCollection
MvvmHelpers.BaseViewModel

Xamarin Community Toolkit

https://docs.microsoft.com/en-us/xamarin/community-toolkit/

Xamarin.Forms ListView – Everything you need to know (& .NET MAUI)

Video