Xamarin.Forms: Lazy loaded Command snippet for Visual Studio

Use xamcomm tab tab to generate commands in ViewModels with this snippet

IntelliSense recommendation

Snippet in work

Save the snippet file as {name}.snippet in Visual Studio’s folder: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC#\Snippets\1033\Visual C#

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
			<Title>Xamarin Lazy Command</Title>
			<Description>Xamarin Command declaration code snippet for MVVM design pattern</Description>
					<ToolTip>Backfield Name</ToolTip>
					<ToolTip>Command name</ToolTip>
					<ToolTip>Action to execute</ToolTip>
					<Default>() => { return; /*TODO: Implement logic for this Command*/ }</Default>
          <ToolTip>Action to determine can execute</ToolTip>
          <Default>() => true</Default>
			<Code Language="csharp">
	private Command $BackFieldName$Command;

	public Command $CommandName$Command
		get { return $BackFieldName$Command ?? ($BackFieldName$Command = new Command($ActionToExecute$,$ActionCanExecute$)); }
This content has 1 year. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.