Useful XAML and MVVM Code Snippets for Xamarin Forms

This post is part of the Xamarin Month’s article for the month of June organized by Louis Matos. You can check his blog and see the list of articles and snippets from all the other auhtors who are participating this month.

In this blog post I will share three (3) code snippets that you can use to increase your productivity when developing applications in Xamarin Forms

  1. Collection View With Linear Layout (XAML)
  2. Collection View With Grid Layout (XAML)
  3. MVVM BaseViewModel with INotifyPropertyChanged (C#)

So let’s look at how to use each of the snippets

1. colview – Collection View With Linear Layout (XAML)

This shortcut should be used in XAML to create a Collection View with Liniear Layout.

Typing this shortcut and pressing the tab key twice will generate this code snippet as show below:

The result of this shortcut is an implementation of Collection View with linear items and other basic properties.

 

2. colviewgrid – Collection View Grid Layout (XAML)

This shortcut should be used in XAML to create a Collection View with Grid Layout.

Typing this shortcut and pressing the tab key twice will generate this code snippet as show below:

The result of this shortcut is an implementation of Collection View with grid items and other basic properties.

 

3. inotify – BaseViewModel with INotifyPropertyChanged (C#)

This shortcut should be used in C# class to create an implementation of a BaseViewModel class with INotifyPropertyChanged

Typing this shortcut and pressing the tab key twice will generate this code snippet as show below:

The result of this shortcut is an implementation of a BaseViewModel class with INotifyPropertyChanged

 

Downloading the Code Snippets

The code snippets are available for download on my github repository.

 

Using the Code Snippets

If you want to see the code snippets in action, watch the video below.

Thank you and happy coding!