Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

proprt - A C# Snippet To Speed Up Writing Windows 8/MVVM Properties

DZone's Guide to

proprt - A C# Snippet To Speed Up Writing Windows 8/MVVM Properties

·
Free Resource

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

image

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

image

...

SNAGHTMLc3f5c09..."

Funny... I was just looking for something like this. I love the inter-tubes.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}