The other day I had to use some enums in WPF, where I wanted them to appear in a ComboBox to allow the user to select one of them.
Imagine that I had enum values like PizzaWithPepperoni, BaconDoubleCheeseBurger etc etc. I managed to get this bound in WPF fairly easily, but I wanted a way of showing some friendly values whilst still maintaining the correct value behind the scenes when a new selection was made.
So I set about doing this, and came up with a solution that used the
EnumMemberAttribute, and then submitted this article to codeproject.
The original article was up for about 2 minutes and Josh Smith, said "ah what about Localization". Damn….luckily another codeproject great, Uwe Keim, posted some code to fix this. I also got a fabulous email from Infragistics great, Andrew Smith, who outlined an alternative approach, which makes use of a MarkupExtension.
I will not post any code/further explanation here as its all talked about in quite a bit of detail within the article.
Here are the relevant links
Andrews Smith alternative approach, which is also a
good (great) read