title: WPF bind enum to combobox
body: <p>In my WPF <code>UserControl</code> I need to bind an <code>Enum</code> on a <code>ComboBox</code>. This <code>enum</code> is declared locally:</p>
  
  <pre><code>public partial class ViewerDataConfiguration : UserControl
  {
      private ViewerDataConfigurationViewModel PageViewModel;
      public Visibility IsParametriSelected { get; set; }
  
      public IEnumerable&lt;eDatoAlarmMode&gt; EnumAlarmModes {
          get
          {
              return Enum.GetValues(typeof(eDatoAlarmMode)).Cast&lt;eDatoAlarmMode&gt;();
          }
      }
  </code></pre>
  
  <p>On the main <code>Grid</code>, where there is a collection bound, I defined a <code>ComboBox</code> as follows:</p>
  
  <pre><code>&lt;TextBox Grid.Column="16" Text="{Binding ConfigObject.Edit.Source}" Style="{StaticResource txtDataStyle2}" Width="30" Visibility="{Binding ConfigObject.Edit, Converter={StaticResource ListaValoriVisibilityConverter}}" HorizontalAlignment="Stretch" TextChanged="Data_TextChanged" /&gt;
  &lt;Label Grid.Column="17" Content="AlarmMode" Style="{StaticResource labelStyle2}" /&gt;
  &lt;ComboBox Grid.Column="18" Width="30"
            ItemsSource="{Binding Path=EnumAlarmModes, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ViewerDataConfiguration}}"
            DisplayMemberPath="Value"
            SelectedValuePath="Value" Style="{StaticResource comboUsersStyle}" /&gt;
  </code></pre>
  
  <p>Basically seems that my <code>IEnumerable</code> is not bound correctly. I see the elements but they're blank. Any hint?</p>