How to bind an enum to a combobox control in WPF?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Binding an enum to a WPF ComboBox is a clean way to present a fixed set of options without duplicating the values in XAML. The usual pattern is to expose the enum values as an ItemsSource and bind SelectedItem or SelectedValue to a ViewModel property of the same enum type.
Start with a Typed ViewModel
The ViewModel should hold the selected enum value, not a string. That keeps the UI and business logic aligned.
PriorityValues provides a simple collection for the ComboBox to display. Because SelectedPriority is strongly typed, the selected item flows directly into application logic.
Bind the ComboBox in XAML
Once the DataContext is set to the ViewModel, the XAML is straightforward.
And in the window code-behind:
This is enough for many internal tools and admin screens.
User-Friendly Display Names
Raw enum names are often acceptable for prototypes, but production UI labels usually need better formatting. A common solution is to apply DescriptionAttribute or DisplayAttribute and then use a converter or helper to show a friendly label.
For example, if the enum contains InProgress, the UI may need "In Progress". The underlying value should remain the enum member, while the display text becomes presentation-specific.
Another lightweight option is to name the enum members exactly as you want them displayed, but that works only when code naming and UI naming can safely match.
Why Binding Beats Manual Item Lists
You could hard-code ComboBoxItem elements in XAML, but that creates duplication and increases the risk of mismatched values. Binding from the enum keeps one source of truth. If a new enum member is added later, the list updates automatically.
That also improves testability. The ViewModel can be validated independently from the WPF view, and the selected value remains a typed enum instead of an arbitrary string.
Common Pitfalls
- Binding the
ComboBoxto strings instead of enum values forces extra parsing later. Bind to the enum type directly when possible. - Forgetting
Mode=TwoWaycan stop the selected value from updating the ViewModel. Use explicit two-way binding for editable selections. - Exposing
Enum.GetValuesincorrectly can produce an awkward collection type in older code. Returning anArrayor a strongly typed list avoids confusion. - Using raw enum member names in a public-facing UI often produces poor labels. Add display metadata or a converter when readability matters.
- Setting the wrong
DataContextmakes the binding appear broken even though the XAML is correct. Verify the view is bound to the intended ViewModel instance.
Summary
- In WPF, bind a
ComboBoxto the enum values throughItemsSource. - Bind
SelectedItemto a ViewModel property of the enum type. - A typed ViewModel is cleaner than string-based parsing.
- Display metadata can improve labels without changing the underlying enum values.
- Enum binding keeps the UI synchronized with the domain model and reduces duplication.

