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.