title: Avalonia Combo box binding
body: <p>I have an Avalonia MVVM based application. I am quite new to Avalonia and MVVM and am now working with combo boxes and bindings. My goal is to change the current view of the application when the user selects a combo box item from the combo box.</p>
  <p>My first approach to handling this was using buttons as the combo box items. With this I was able to bind a command that allows the view to change via the view-model. This approach works, but its not appealing to have a button as a combo box item.</p>
  <p>My real issue is that I am not sure if I can communicate my combo box with my view-model.</p>
  <p>Any kind of help would be appreciated.</p>
  <p>Below is the .AXAML</p>
  <pre><code>&lt;ComboBox Grid.Column=&quot;0&quot; HorizontalAlignment=&quot;Center&quot; x:Name=&quot;ProductComboBox&quot; PlaceholderText=&quot;Products&quot; Cursor=&quot;Hand&quot; Background=&quot;Transparent&quot;&gt;
                         
                              &lt;ComboBoxItem HorizontalAlignment=&quot;Center&quot;&gt;Beef&lt;/ComboBoxItem&gt;
                              &lt;ComboBoxItem HorizontalAlignment=&quot;Center&quot;&gt;Chicken&lt;/ComboBoxItem&gt;
                              &lt;ComboBoxItem HorizontalAlignment=&quot;Center&quot;&gt;Fish&lt;/ComboBoxItem&gt;
  &lt;/ComboBox&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/7NCde.png" rel="nofollow noreferrer">Image of combo box without buttons</a></p>
  <p>Below is the button approach:</p>
  <pre><code>&lt;ComboBox Grid.Column=&quot;1&quot; HorizontalAlignment=&quot;Center&quot; SelectedIndex=&quot;0&quot; Cursor=&quot;hand&quot;&gt;
                          &lt;ComboBoxItem HorizontalAlignment=&quot;Center&quot;&gt;
                              &lt;Button Content=&quot;Fresh cuts&quot; HorizontalAlignment=&quot;Stretch&quot; Cursor=&quot;Hand&quot; Command=&quot;{Binding ToFreshCutsPage}&quot;/&gt;
                          &lt;/ComboBoxItem&gt;
                          &lt;ComboBoxItem HorizontalAlignment=&quot;Center&quot;&gt;
                              &lt;Button Content=&quot;Butcher's choice&quot; HorizontalAlignment=&quot;Stretch&quot; Cursor=&quot;Hand&quot; Command=&quot;{Binding ToButcherChoicePage}&quot;/&gt;
                          &lt;/ComboBoxItem&gt;
                          &lt;ComboBoxItem HorizontalAlignment=&quot;Center&quot;&gt;
                              &lt;Button Content=&quot;Discounts&quot; HorizontalAlignment=&quot;Stretch&quot; Cursor=&quot;Hand&quot; Command=&quot;{Binding ToDiscountsPage}&quot;/&gt;
                          &lt;/ComboBoxItem&gt;
  &lt;/ComboBox&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/vE7Ip.png" rel="nofollow noreferrer">Image of combo box with buttons</a></p>