I
I
iRumba2015-04-27 11:44:23
WPF
iRumba, 2015-04-27 11:44:23

How to bind (binding) to enumeration (enum), excluding unnecessary elements?

Hello. There is a lot of help on binding, but I didn't find binding conditions. How can I exclude an unnecessary element from the list?
Well, for example, there is an Enum type: int
None = 0,
Nuber1 = 1,
number2 = 2
Tell me, how can I display all this in xaml in a ComboBox, for example, excluding the None value?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Kulakov, 2015-04-27
@iRumba

I think you can create the desired list of values ​​​​and bind it already.
1)Enum.GetValues(typeof(T)) - get all values ​​from Enum.
2) Enum.GetValues(typeof (T)).Cast() - get an IEnumerable
3 ) here using, for example, Where() filter out unnecessary values
​​4) form a List using ToList()
and use it in the ComboBox

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question