Wednesday, 28 March 2012

ViewModels for Enums

Here is a neat trick for providing a generic view model for your enums:

image

The DisplayText is looked up from a resource file containing strings for the application. 

There is also a little static helper class for enums, which doesn’t do a lot but I think helps to keep code a little cleaner:

Source code including unit tests:  http://stevenhollidge.com/blog-source-code/EnumViewModel.zip

1 comment: