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)]
.
What am I missing?
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?