Skip to content

Instantly share code, notes, and snippets.

@CheetahChrome
Created June 27, 2019 18:04
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 CheetahChrome/54d61381a2da6fe8dbeb3a3c69595f0b to your computer and use it in GitHub Desktop.
Save CheetahChrome/54d61381a2da6fe8dbeb3a3c69595f0b to your computer and use it in GitHub Desktop.
Visual Studio Snippet to Work on a VM to add a Notified Property
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>NotifiedProperty</Title>
<Author>William Wegerson</Author>
<Description>Same as the propfull snippet except it adds OnPropertyChanged to the setter.
</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>propnot</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>Type</ID>
<ToolTip>Type</ToolTip>
<Default>Type</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>PropertyName</ID>
<ToolTip>PropertyName</ToolTip>
<Default>PropertyName</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
private $Type$ _$PropertyName$;
public $Type$ $PropertyName$
{
get { return _$PropertyName$; }
set { _$PropertyName$ = value; OnPropertyChanged("$PropertyName$"); }
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
@CheetahChrome
Copy link
Author

CheetahChrome commented Jun 27, 2019

Similar to Visual Studio's snippets of prop or propfull, this is my Visual Studio snippet which does the same as propfull except it adds notification in the set. Ex:

 private string _Message;

 public string Message
 {
       get { return _Message; }
       set { _Message = value; OnPropertyChanged("Message"); }
  }

I have always used these Control dependency property snippets Helpful Silverlight Snippets in all versions of XAML. But this is my personal one which can be used on the VM instead of a control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment