Question

I have an enum that bind to a ComboBox in my view.

public enum MyItems
{
    [Browsable(false)]
    Item1,

    [Browsable(true)]
    Item2,

    [Browsable(false)]
    Item3,

    [Browsable(true)]
    Item4,
}

In view I use ObjectDataProvider

 <ObjectDataProvider x:Key="eMyItems" MethodName="GetValues"
                        ObjectType="{x:Type System:Enum}">
        <ObjectDataProvider.MethodParameters>
            <x:Type TypeName="Enums:MyItems"/>
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>:

My ComboBox look like this:

<ComboBox  ItemsSource="{Binding Source={StaticResource eMyItems}}" SelectedValue="{Binding Item}"/>

The problem is that I see all the Enum even the ones that above them have [Browsable(false)].

enter image description here

What am I missing?

Was it helpful?

Solution

One of the answers in this related question looks like it might be of help to you:

WPF Data binding: How to data bind an enum to combo box using XAML?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top