Binding Flagged Enumerations(blog.virtual-olympus.com)

submitted by thejetthejet(156) 7 months, 14 days ago

Flagged enumerations can present a difficult problem for data binding, this article presents a solution for binding these enumerations to individual CheckBox(s) in a WPF sample application.

4 comments |category: |Views: 26

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by dpetersondpeterson(4397) 7 months, 14 days ago 0

Very clever solution! I agree that leveraging the viewmodel is a much cleaner approach.
Do you think you could expand a little more on what's going on with your FlaggedEnumViewModel class?

Reply

posted by thejetthejet(156) replied to dpetersondpeterson(4397), 7 months, 10 days ago 0

I'd be happy to, do you have any specific questions? Really the brunt of what's going on is the translation of the convention-based property name into the associated flag, then checking against the underlying data to return the correct boolean, or set/clear the appropriate bit on the underlying value.

Reply

posted by bradygasterbradygaster(4897) 7 months, 14 days ago 0

Excellent code. This is one of those "it-seems-like-it'd-be-easy" things that is explained really well. I'd like to see the author do some deeper discussion and maybe describe how to do dynamic binding in WPF.

Reply

posted by thejetthejet(156) replied to bradygasterbradygaster(4897), 7 months, 10 days ago 0

Thanks! I do plan to do additional posts in the future, but time [and interesting topics] are hard to come by :)

Reply

information Login or create an account to comment on this story