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 Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s