When I install or upgrade a new version of Visual Studio, or when I am on a computer of a colleague, I am always missing some snippets. So here I will collect each one.
propvm
private $type$ _$name$; public $type$ $name$ { get => _$name$; set => SetProperty(ref _$name$, value); }
(Windows, propvm.snippet)
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>propvm</Title> <Shortcut>propvm</Shortcut> <Description>snippet for view model property including the backing field</Description> <Author>Thomas Kison</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>type</ID> <ToolTip>property type</ToolTip> <Default>string</Default> </Literal> <Literal> <ID>property</ID> <ToolTip>property name</ToolTip> <Default>MyProperty</Default> </Literal> </Declarations> <Code Language="csharp"> <![CDATA[private $type$ _$property$; public $type$ $property$ { get => _$property$; set => SetProperty(ref _$property$, value); } $end$]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
cmd
#region $name$ ICommand _$name$Command; public ICommand $name$Command => _$name$Command = _$name$Command ?? new DelegateCommand(Do$name$); private void Do$name$() { } #endregion
(Windows, cmd.snippet)
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>cmd</Title> <Shortcut>cmd</Shortcut> <Description>snippet for a delegate command</Description> <Author>Thomas Kison</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>cmdName</ID> <ToolTip>name of the command</ToolTip> <Default>My</Default> </Literal> </Declarations> <Code Language="csharp"> <![CDATA[ #region $cmdName$Command ICommand _cmd$cmdName$; public ICommand $cmdName$Command { get => _cmd$cmdName$ = _cmd$cmdName$ ?? new DelegateCommand($cmdName$); } private void $cmdName$() { } #endregion $end$]]></Code> </Snippet> </CodeSnippet> </CodeSnippets>