Wednesday, January 18, 2012

Comfortably numb... MVVM'ing Enums in ComboBox

The Angry Programmer - MVVM ComboBox with Enums

"I decided to write an MVVM version of binding enum values to a ComboBox for WPF. I know there are lots of examples of how to put enum values into combo boxes, but most of them either use ObjectProvider or derive their own class from ComboBox. I don’t like inheritance, I prefer extending classes, as it keeps things cleaner and lets you choose whether to use the facility or not.

To that end, I have come up with a behaviour to populate the ComboBox with enum values.

We’ll start off with the enum I’m going to use called JobTitles.



This is something I have to fight with from time to time and I liked seeing a different approach to solving this.

No comments: