Create RaisePropertyChnged Property Snippet using Visual Studio 2010
Ever you wanted to create your own snippet in Visual Studio 2010. Let me guess, you think of writing xml file and all that. Well there is an easy way. Snippet Designer has an extension for Visual Studio 2008/2010/2012.
You could download it from Codeplex, or you could search it in Visual Studio Extension Manager. Just search for snippet in Online Gallery and you would have it for download.
After you download it, install it. And most importantly restart Visual Studio. Now you open up your existing project that you were working on. This would not create any file in your project.
Then as displayed below, create a new file using the File à New àFile.
Or you could press the shortcut CTRL + N.
The following New File dialog would pop up. Select “Snippet Designer” from it and Click on Open.
After that your snippet file would be opened in your Visual Studio IDE. First thing you should do now, is to save the file.
Remember that, you should keep the file in the default folder “—-/My Code Snippets” folder, else the shortcut would not work. Ofcourse you can keep a copy of all your snippets anywhere else for backup.
Then choose your Language from the dropdown. In this sample we are going to use C#.
Write your code snippet. Like I have written for a Property that has RaisePropertyChanged, which is INotifyPropertyChanged capable.
Then, you need select the word you need to replace option aware. Double click on string and right click on it and select “Make Replacement”.
As you see below, the replacement has changed the code as following.
Similarly, we would do the rest.
You are almost done. You have to add a shortcut to the snippet, in this example I am adding it as “propra”.
You are done.
Now you could start typing propra and press Tab. And you would be able to change the replaceable terms that you have already defined in the snippet.
Source Code: Click Here
Article as PDF: Click Here