Binding And Using Localized Enums In WPF

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

My article

http://www.codeproject.com/KB/WPF/FriendlyEnums.aspx

Andrews Smith alternative approach, which  is also a good (great) read

http://agsmith.wordpress.com/2008/09/19/accessing-enum-members-in-xaml/

2 Comments so far »

  1. Uwe said

    am September 20 2008 @ 2:26 pm

    Wow, cool, thanks for mentioning me!

  2. sacha said

    am September 20 2008 @ 6:00 pm

    No worries man

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: