title: Set default value in a combo box using MVVM
body: <p>I'm trying to set a default value into a combo box when the application is first loading using the MVVM pattern and it looks like this is all the time unset, combo box being all the time empty when the page loads.</p>
  
  <p>This is my xaml:</p>
  
  <pre><code>    &lt;ComboBox Grid.Row="0" Margin="10,0,0,0" Grid.Column="1" 
                SelectedItem="{Binding Path=JuiceOperations.SelectedItemOption, Mode=TwoWay}"
                SelectedIndex="{Binding Path=JuiceOperations.SelectedComboBoxOptionIndex, Mode=TwoWay}"
                SelectedValue="{Binding Path=JuiceOperations.SelectedComboBoxOptionIndex, Mode=TwoWay}"
                ItemsSource="{Binding Path=JuiceOperations.JuiceOptions}" /&gt;
  </code></pre>
  
  <p>This is the view model code, with its default constructor:</p>
  
  <pre><code>    public JuiceViewModel()
      {
          juiceOperations.SelectedComboBoxOptionIndex = 0;
          juiceOperations.SelectedItemOption = "Cola";
      }
  </code></pre>
  
  <p>where I am trying to set the default value of the combo box.</p>
  
  <p>And this is how the properties looks like:</p>
  
  <pre><code>private List&lt;string&gt; juiceOptions = new List&lt;string&gt; { "Cola", "Sprite", "Fanta", "Pepsi" };
  
      private string selectedItemOption = string.Empty;
  
      private int selectedComboBoxOptionIndex = 0;
  
      public int SelectedComboBoxOptionIndex
      {
          get
          {
              return this.selectedComboBoxOptionIndex;
          }
  
          set
          {
              this.selectedComboBoxOptionIndex = value;
              this.OnPropertyChanged("SelectedComboBoxOptionIndex");
          }
      }
  
      public List&lt;string&gt; JuiceOptions
      {
          get
          {
              return this.juiceOptions;
          }
  
          set
          {
              this.juiceOptions = value;
          }
      }
  
      public string SelectedItemOption
      {
          get
          {
              return this.selectedItemOption;
          }
  
          set
          {
              this.selectedItemOption = value;
              this.OnPropertyChanged("SelectedItemOption");
          }
      }
  </code></pre>
  
  <p>When selecting an item from combo box the selection is updated into the model and also into the view, so it is working as expected but when the page is first loaded even if the "SelectedComboBoxOptionIndex" and "SelectedItemOption" are being called and their value updated the view of the page is not updated and the empty string is being shown into the combo box where I was expected to see the "Cola" value, instead of the empty string.</p>
  
  <p>Can someone explain me what I am doing wrong and how should I set the default  "Cola" value into the combo box ?</p>