Binding to enumerations

In previous blog posts, I’ve talked about how you can use XAML to bind to various items. Here, I’d like to show you how to simply bind to an enumeration. I love the fact that binding does so much for you without you having to do much at all.

First of all, we’ll look at the XAML, and then we’ll go over the code.

In the resources section, we create a data provider that calls the GetValues method on an enumeration. Obviously we need to identify the enumeration that we are interested in, so we supply the relevant enumeration in the MethodParameters.

Finally, it’s a simple case of binding to our object data source. You’ve gotta love WPF.

2 thoughts on “Binding to enumerations

    1. peteohanlon

      I agree – to be honest, the reason I did this was for the MoXAML addin which allowed me to bind to a couple of API enumerations, hence they didn’t need to be localized, but I take your point.

Leave a comment