Creating Your First Windows 8 Application

  • 12/15/2012
In this chapter from Start Here! Learn Microsoft Visual Basic 2012, you’ll learn how to create your first Windows 8 application from scratch.

After completing this chapter, you’ll be able to

  • Create the user interface for a Windows 8 application.

  • Add XAML controls to a page.

  • Move and resize objects on a page.

  • Set the properties for objects in the user interface.

  • Write Visual Basic program code for an event handler.

  • Save, run, and test a program.

  • Build an executable file and deploy the application.

Chapter 1, “Getting to Know Visual Basic 2012” introduced you to Microsoft Visual Studio 2012 and the development tools that you can use to build Microsoft Visual Basic applications. In this chapter, you’ll learn how to create your first Windows 8 application from scratch. The program will be a simple Internet-browsing tool that displays active webpage content in a window and also keeps track of the web addresses that you use as you run the program.

Although the project itself is quite basic, it will teach you essential programming techniques that you will use each time that you write a program. You will create a basic user interface with XAML controls, adjust property settings for the controls, and add Visual Basic program code to create an event handler. Along the way, you’ll learn how to use the Visual Studio Toolbox, how to use the Button, TextBox, and WebView controls, and how to use the Code Editor to create a Visual Basic code-behind file for the user interface. You’ll also learn how to run and test a program, how to save your changes, and how to deploy an application so that it is ready to use on your computer.

Web List: Your First Visual Basic Program

The Windows 8 application that you are going to create is Web List, a program that displays live webpage content and also keeps track of the web sites that you visit in a text box. The tool allows you to rapidly examine and record a list of favorite web sites, and it also shows you how to view web site information directly on the home page of an application. Here’s what the Web List program will look like when it’s finished:

The Web List user interface contains one button, two text boxes, and a web browser window that allows you to examine the live contents of any web site you wish. I produced these elements by creating four objects on the Web List application page and then changing several properties for each object. After I designed the user interface, I used Visual Basic program code to create an event handler for the Visit Web Site button, which executes when the user types a web address in the first text box and clicks the Visit Web Site button. To re-create Web List, you’ll follow three essential programming steps in Visual Studio: creating the user interface, setting the properties, and writing the Visual Basic program code. The following list outlines the development process for Web List:

  1. Create the user interface (requires four objects).

  2. Set the properties (requires nine properties).

  3. Write the program code (requires one object).