Code Snippet to automatically create getter/setter?
If you are already using the MVVM Light framework you can install the code snippets that ship with it that will do something similar. Specifically the "mvvminpc" snippet will do what you are looking for, although it will not take an existing field declaration and convert it to a property with a propertychanged notification.
http://mvvmlight.codeplex.com/sourcecontrol/latest#Installer/InstallItems/Snippets/CSharp/mvvmInpc.snippet
Code snippets to speed up the addition of new properties (Visual Studio only):
mvvminpc adds a new bindable property to a ViewModel.
mvvmlocatorproperty adds a new ViewModel to a ViewModeLocator.
mvvmpropa adds a new attached property to a DependencyObject (WPF only).
mvvmpropdp adds a new dependency property to a DependencyObject (WPF only).
mvvmslpropa adds a new attached property to a DependencyObject (Silverlight only).
mvvmslpropdp adds a new dependency property to a DependencyObject (Silverlight only).
put this snippet:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Shortcut>propn</Shortcut>
<Title>
Notify Property
</Title>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Type</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>field</ID>
<ToolTip>Field name</ToolTip>
<Default>fieldName</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Propery Name</ToolTip>
<Default>PropertyName</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[
private $type$ $field$;
public $type$ $property$
{
get { return $field$; }
set
{
if($field$ != value)
{
$field$ = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("$property$"));
}
}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
inside a file propn.snippet, in this folder: C:\Users[YOUR_USERNAME]\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets
and afterwards you'll be able to use this snippet using the (propn + tab + tab) shortcut.
the snippet xml is very easy to understand on your own, so you can easily adjust it to whatever you need.