[]
        
(Showing Draft Content)

Selecting Items

The SelectedIndex property determines which item is selected in a drop-down list. The SelectedIndex is based on a zero-based index, meaning that 0 represents the first C1ComboBoxItem, 1 represents the second C1ComboBoxItem, and so on. In the image below, the SelectedIndex is set to 2, which selects the third C1ComboBoxItem.

In XAML

To set a selected item, add SelectedIndex="0" to the <c1:C1ComboBoxItem> tag so that the markup resembles the following:

<c1:C1ComboBoxItem Content="C1ComboBoxItem1" SelectedIndex="1">

In Code

Complete the following steps:

  1. Open the MainWindow.xaml.cs or the MainPage.xaml.cs page (or the MainWindow.xaml.vb page for Visual Basic).
  2. Add the following code beneath the InitializeComponent() method:
C1ComboBoxItem1.SelectedIndex = 1
c1ComboBoxItem1.SelectedIndex = 1;
  1. Run the program.

In the Designer

Complete the following steps:

  1. Select the C1ComboBox control.
  2. In the Properties window, set the SelectedIndex property to "1" so that the second C1ComboBoxItem will be selected.