Press "Enter" to skip to content

Xamarin Forms Prism Code Snippets

This article is part of the code snippets June calendar by Luis Matos, click here to check all the great contributions.

When developing a Xamarin Forms Prism application there’s code that we always use such as navigating, container registrations, initializations, display of alerts, etc. In this post, I will share some code snippets that cover these tasks and that can be imported and used in Visual Studio.

Here is the list of code snippets:

  • Application Class Implementation
  • Android Platform Initializer Class
  • iOS Platform Initializer Class
  • Container Page Registration
  • Container Instance Registration
  • Container Service Registration
  • BaseViewModel Class
  • Display an Alert
  • Display an ActionSheet
  • Navigation & Modal Navigation with/without params
  • DelegateCommand

Application Class implementation

Snippet: papp

Android Platform Initializer Class

Snippet: pinitdroid

iOS Platform Initializer Class

Snippet: pinitios

Container Page registration

Snippet: pregnav

Container Instance Registration

Snippet: pregin

Container Service Registration 

Snippet: pregserv

BaseViewModel Class

Snippet: pbvm

Display an Alert

Snippet: palert

Display an ActionSheet

Snippet: pasheet

Navigation 

Snippet: pnav

With params:

Snippet: pnavparam

Modal Navigation 

Snippet: pnavm

With params:

Snippet: pnavmparam

Delegate Commands 

Snippet: pcmd

Import the code snippets

You can download all these snippets here.

To import them in Visual Studio you just have to go to your Visual Studio snippets folder ( Mac: ~/Library/VisualStudio/8.0/Snippets or PC : \Visual Studio 2019\Code Snippets\C#), paste the snippets there and re-open VisualStudio.

For more information check.

Happy Prism Snippets!