title: Binding ComboBox to Enum Dictionary in UWP
body: <p>I have a UWP app where I'm binding a ComboBox to a Dictionary. This is sort of working except for one issue. When I try to set the bound SelectedValue in my view model, the ComboBox resets to a null state.</p>
  
  <p>I tried doing the exact same thing in WPF, and it doesn't have this issue. Looking online, I found <a href="http://www.codeproject.com/Tips/1068717/Very-Friendly-Enum-Binding-In-WPF" rel="nofollow">this</a> page doing exactly what I'm doing with WPF, but I couldn't find anything on UWP.</p>
  
  <p>What do I need to do to make the ComboBox not reset when updating the bound value?</p>
  
  <p>Here's a simplified example. I'm using PropertyChanged.Fody and MvvmLightLibs</p>
  
  <p>View Model:</p>
  
  <pre><code>[ImplementPropertyChanged]
  public class ViewModel
  {
      public ICommand SetZeroCommand { get; set; }
      public ICommand ShowValueCommand { get; set; }
  
      public ViewModel()
      {
          SetZeroCommand = new RelayCommand(SetZero);
          ShowValueCommand = new RelayCommand(ShowValue);
      }
      public Numbers Selected { get; set; } = Numbers.One;
      public Dictionary&lt;Numbers, string&gt; Dict { get; } = new Dictionary&lt;Numbers, string&gt;()
      {
          [Numbers.Zero] = "Zero",
          [Numbers.One] = "One",
          [Numbers.Two] = "Two"
      };
  
      private async void ShowValue()
      {
          var dialog = new MessageDialog(Selected.ToString());
          await dialog.ShowAsync();
      }
  
      private void SetZero()
      {
          Selected = Numbers.Zero;
      }
  
      public enum Numbers
      {
          Zero,
          One,
          Two
      }
  }
  </code></pre>
  
  <p>Xaml:</p>
  
  <pre><code>&lt;Page
      x:Class="UwpBinding.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:UwpBinding"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      DataContext="{Binding MainWindow, Source={StaticResource Locator}}"&gt;
      &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
          &lt;ComboBox Margin="105,163,0,0" ItemsSource="{Binding Dict}" DisplayMemberPath="Value" SelectedValuePath="Key" SelectedValue="{Binding Selected, Mode=TwoWay}"/&gt;
          &lt;Button Content="Show" Command="{Binding ShowValueCommand}" Margin="25,304,0,304"/&gt;
          &lt;Button Content="Set to 0" Command="{Binding SetZeroCommand}" Margin="10,373,0,235"/&gt;
      &lt;/Grid&gt;
  &lt;/Page&gt;
  </code></pre>