I once used a code snippet I saw/found in the past that would turn my single statement into a private/public getter/setter, I've been so far unable to repeat that find since reinstalling my machine.
for example:
private string serverSMTP = string.empty;
I could then press Ctrl k + and turn it into this:
private string serverSMTP = string.Empty;
public string ServerSMTP
{
get { return serverSMTP; }
set
{
serverSMTP = value;
RaisePropertyChanged("ServerSMTP");
}
}
Any ideas on how I can create something to do that or an extension/snippet to take care of it for me? In larger projects this would save me a lot of time.
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.
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).