0

I'm using the MarkupExtension outlined in this answer for binding my enums to ComboBoxs: Databinding an enum property to a ComboBox in WPF

Which is convenient because it allows me to do something like this:

<ComboBox 
    ItemsSource="{util:Enumeration {x:Type viewModels:MyEnumTypeE}}" 
    DisplayMemberPath="Description" 
    SelectedValue="{Binding MyEnumValue, FallbackValue=0}"   
    SelectedValuePath="Value" />

which is what I'm used to seeing when I bind my ComboBoxs to most anything else.

I'm having trouble, however, because now I need to filter out certain enumeration values. I also need to selectively filter them out at run-time, so that sometimes all of my enum values are displayed, and sometimes only a few of the values are displayed.

This question, Binding WPF ComboBox to enum and hiding certain values, seemed like the perfect title to answer the question, but they are using the ObjectDataProvider which I am not. I suppose I could always default back to using that if I really needed to, but since the MarkupExtension is just so darn convenient, I would like to continue using that instead.

My question is: how could I filter out some enum values from my ComboBox while still using this MarkupExtension?

Community
  • 1
  • 1
DeathTails
  • 468
  • 4
  • 12
  • Can't you use another attribute ( for instance `Browsable`) for filtering? – Ivan Stoev Oct 12 '15 at 19:06
  • Honestly, I know very little about attributes. I may have to play around with them a bit. Do you know if I can toggle it on/off during run-time? Sometimes my entire enum needs displayed; sometimes only part of it. – DeathTails Oct 12 '15 at 19:18
  • That's the point - no. Attributes can only be used for static behavior. If you need dynamic filtering, you need something else. Which I don't know what could be. – Ivan Stoev Oct 12 '15 at 19:22

0 Answers0