1. Home
  2. Computing & Technology
  3. Visual Basic

WPF Tutorial Part 3: A First Introduction to WPF and XAML for Visual Basic
Programming a WPF and XAML Application

By , About.com Guide

Dec 12 2009

If you haven't looked at part 1 of this series, you might want to go back and check it out first. Also, all code here is based on VB.NET 2008 Express, to be certain that you can use totally free software.

This is a good time to remind you that you really need the latest version of VB.NET, VB.NET 2008, to do WPF applications. I'm using VB.NET 2008 Express Edition here. You can download that free of charge from Microsoft. Just search for the name at Microsoft.com to find the download page.

In part 2 of this series, a "Hello World" application was shown that used the ability of WPF to vary the opacity of a WPF Label component, so we won't do that one again. In fact, you don't even need Visual Basic at all to display "Hello World" in XAML. Simply add this XAML code to a text file in Notepad ...

<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock Text="Hello From About Visual Basic" />
</Page>

Save the file as AVBHello.xaml and double click the file. You should get a nice display in your browser. (Note that not all browsers are XAML compatible!)

--------
Click Here to display the illustration
Click the Back button on your browser to return
--------

As you look at XAML examples, keep in mind that - just as in all other Microsoft technologies - there are equivalent ways of doing thing. For example, the XAML application above could also have been coded using a child element rather than a Text attribute like this:

<Page
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   <TextBlock>
      Hello From About Visual Basic
   </TextBlock>
</Page>

Most attributes can be replaced by a child element in a similar way.

On the next page, we develop a complete application using only XAML that actually does something.

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Using VB.NET
  5. WPF Tutorial Part 3: A First Introduction to WPF and XAML for Visual Basic Programmers

©2009 About.com, a part of The New York Times Company.

All rights reserved.