Creating a list of items
Lists are typically used to show a collection of related objects. WPF provides several controls which can be used for that purpose, such as
ComboBox (which can be considered classic). All these derive from
ItemsControl, which defines some basic functionality, such as an
Items property. In this recipe, we'll take a quick look at
ComboBox. We'll reserve a more detailed explanation for Chapter 6, Data Binding, as this is the typical way list-based controls are used in WPF.
Make sure Visual Studio is up and running.
How to do it…
- Create a new WPF application named
MainWindow.Xaml. Add two rows to the existing
Grid, as follows:
<Grid.RowDefinitions> <RowDefinition Height="Auto" ...