The Brain Dump - Windows 8 ViewModel Property Code Snippet
Visual Studio provides a bunch of good code snippets for creating boilerplate code. For example if you type “prop” you get this in intellisense
You’ll see a few nice property snippets.
- prop – creates a basic automatic property
- propa – creates an attached property
- propdp – creates a dependency property
- propfull – creates a public property with a private backing field
- propg – creates a basic automatic property but the set is marked private
I use these constantly but hit an issue when building my Windows 8 apps. For ViewModels in Windows 8, the default templates take advantage of a wonderful attribute CallerMemberName in the OnPropertyChanged method of the ViewModel base class. This allows you to create properties that support notifications in a very simple manner. Like this
...
Funny... I was just looking for something like this. I love the inter-tubes...
No comments:
Post a Comment
NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...
ALL comments are moderated. I will review every comment before it will appear on the blog.
Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...
I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...
Please see my comment policy for more information if you are interested.
Thanks,
Greg
PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...