Adding ComboBox Items from a Collection

In this topic, you will populate a combo box's drop-down list with a collection.

Complete the following steps:

1.   Open the MainPage.xaml.cs page.

2.   Import the following namespace into the project:

      Visual Basic

      C#

3.   Create your list by adding the following code beneath the InitializeComponent() method:

      Visual Basic

      C#

4.   Add the list to the combo box by setting the ItemsSource property:

      Visual Basic

      C#

5.   Run the program.

 This Topic Illustrates the Following:

With the project running, click the drop-down arrow and observe that four items appear in the drop-down list. The result resembles the following image:

 


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.