
Chapter 8: Building Desktop Applications with WPF | 241 |
VB:
Private Sub Window_Loaded(
ByVal sender As System.Object,
ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
Dim OrderViewSource As CollectionViewSource = CType(FindResource("OrderViewSource"), CollectionViewSource)
OrderViewSource.Source = New List(Of Order) From
{
New Order With
{
.OrderDate = DateTime.Now
}
}
CustomerIDComboBox.ItemsSource =
From cust In New MyShopDataContext().Customers
End Sub
The previous
Configuring a ComboBox
A couple of the particularly more complex controls to configure are ComboBox and ListBox. The reason is that they have a few different properties that must be set to ensure that whatever is selected can be read and correctly referenced back to the original data source. This section doesn’t try to teach you about WPF binding because there are entire books with multiple chapters related to the subject. Instead, you’ll learn an essential skill for helping you figure out how to set the right properties on a ComboBox control. In so doing, you’ll get a better feel for the features of VS that help you perform the task of setting up controls.