O'Reilly logo

Windows Application Development Cookbook by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a listbox

In the case of the collapsed ComboBox control, only one item is presented. However, if you want to show more items as well as allow to select multiple elements in the same time, you can use ListBox. The usage of this control is explained in this recipe.

Getting ready

To step through this recipe, you only need the automatically generated project.

How to do it...

To add a listbox and handle the SelectionChanged event, perform the following steps:

  1. Place the ListBox control with the supported languages on the page and adjust its appearance by modifying the content of the MainPage.xaml file as follows:
            <Page (...)> 
                <Grid (...)> 
                    <ListBox SelectedIndex="1" SelectionMode="Single" VerticalAlignment="Center" HorizontalAlignment="Center"> <ListBoxItem ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required