Created
June 28, 2021 03:19
-
-
Save ShuhuaGao/bff38344143717ace1a468c78efcf338 to your computer and use it in GitHub Desktop.
Property snippet with change notification in Stylet MVVM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8" ?> | |
| <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
| <CodeSnippet Format="1.0.0"> | |
| <Header> | |
| <Title>props</Title> | |
| <Shortcut>props</Shortcut> | |
| <Description>Code snippet for property and backing field and notify with Stylet</Description> | |
| <Author>Gao Shuhua</Author> | |
| <SnippetTypes> | |
| <SnippetType>Expansion</SnippetType> | |
| </SnippetTypes> | |
| </Header> | |
| <Snippet> | |
| <Declarations> | |
| <Literal> | |
| <ID>type</ID> | |
| <ToolTip>Property type</ToolTip> | |
| <Default>int</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>property</ID> | |
| <ToolTip>Property name</ToolTip> | |
| <Default>MyProperty</Default> | |
| </Literal> | |
| <Literal> | |
| <ID>field</ID> | |
| <ToolTip>The variable backing this property</ToolTip> | |
| <Default>myVar</Default> | |
| </Literal> | |
| </Declarations> | |
| <Code Language="csharp"> | |
| <![CDATA[private $type$ $field$; | |
| public $type$ $property$ | |
| { | |
| get => $field$; | |
| set => SetAndNotify(ref $field$, value); | |
| } | |
| $end$]]> | |
| </Code> | |
| </Snippet> | |
| </CodeSnippet> | |
| </CodeSnippets> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HOW TO USE
Stylet.PropertyChangedBasethat defines theSetAndNotifymethod.