Skip to content

Instantly share code, notes, and snippets.

@bjcull
Created September 16, 2012 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjcull/3730960 to your computer and use it in GitHub Desktop.
Save bjcull/3730960 to your computer and use it in GitHub Desktop.
Property with NotifyOfPropertyChange Code Snippet. To be used with the Caliburn.Mircro library.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Property with Notify Snippet</Title>
<Author>Ben Cull - http://benjii.me</Author>
<Description>Inserts a full property with a NotifyOfPropertyChange statement as well. To be used with the Caliburn.Mircro library.</Description>
<Shortcut>propnfy</Shortcut>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[private $type$ $privateVar$;
public $type$ $publicVar$
{
get { return $privateVar$; }
set
{
if ($privateVar$ != value)
{
$privateVar$ = value;
NotifyOfPropertyChange(() => $publicVar$);
}
}
}]]>
</Code>
<Declarations>
<Literal>
<ID>privateVar</ID>
<ToolTip>Replace with the private variable name</ToolTip>
<Default>_myVar</Default>
</Literal>
<Literal>
<ID>publicVar</ID>
<ToolTip>Replace with the public variable name</ToolTip>
<Default>MyVar</Default>
</Literal>
<Object>
<ID>type</ID>
<Type>System.Type</Type>
<ToolTip>Replace with the variable type</ToolTip>
<Default>Type</Default>
</Object>
</Declarations>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment