O'Reilly logo

Professional Visual Basic 2012 and .NET 4.5 Programming by Todd Herman, Gastón Hillar, David McCarter, Rob Windsor, Billy Hollis, Bill Sheldon

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

Preparing the Sample Application

Chapter 1 provided you with a Windows Presentation Foundation (WPF) application that serves as a base for most of the other chapters in this book. This chapter uses this base application, but you are going to make a few changes to it. These changes are specific to this chapter and should not be assumed to be valid in other chapters.

The first thing to change in the base application is the design of the main window: You need to change the layout grid to include a second column. Next you add a ComboBox to the form and put it in the first column using Grid.Column=”0”. To ensure the combo box is correctly bound to the data on the back end, add the following properties and values:

  • ItemsSource = {Binding}
  • DisplayMemberPath = “Name”
  • SelectedValuePath = “Lambda”

Now you need to ensure the Button that was in the original application is in the second column by using Grid.Column=”1”. You can add a Margin to both controls to make them look a little better on the form. You should also name the new combo box ExampleList and the button ExecuteButton. Since the button's name changed, you will need to change the event handler name accordingly. Once these changes are complete your code should resemble the code in Listing 5-1.

Listing 5.1 : MainWIndow — MainWindow.xaml

<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Pro VB 2012 Chapter 5" Height="400" Width="400"> ...

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