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.
We've seen all of the individual techniques necessary to write a complete application in the earlier parts of this series. It's time to 'get serious' and write something useful.
In additon to WPF and XAML, this application also uses an XML file to save the trip information. The "LINQ to XML" feature that is new in Framework 3.5 is used to maintain the XML information so you might be interested in this article for that reason too.
When I plan a trip, I like to make sure that each day is covered with the essentials for each day.
- Where I stay the night
- How I get to that place
- Any events that happen on that day
I've always done this by entering text in Word or Notepad. And I've always thought I ought to write a program to do it instead, but I've never worked up the ambition to actually do it. When I thought about an application to cap this series on WPF and XAML, this long deferred project came to mind.
This application is "complete" in the sense that it does all of the basic functions I need. But a lot of "supporting code" that does things such as error checking has been left out since they would at least double the volume of source code and they're pretty standard functions that most programmers reading this article should already be familiar with.
To cement the WPF concepts in place, the three forms used in this application use two different design styles.
MainWindow uses a DockPanel containing a StackPanel design. This design works for holding other components that don't need to be resized and naturally stack vertically. Since none of the items here have to change size, that works great for this form.
TripDesc and AddADay both use a Grid component to contain individual components. This is the default provided by Visual Studio and allows very precise control over component placement. The Margin attribute controls vertical size but the form can be resized horizontally and the components resize dynamically.
And ... before getting into details ... there's one more detail. As a real application, supporting the functions was the first priority. So I 'just figgered out' the code that will work. There could be better ways to do a lot of these functions and if there are, I'd love to hear about them.
The basic functions in this simple application are shown in this diagram:
--------
Click Here to display the illustration
Click the Back button on your browser to return
--------
The application consists of three WPF forms (the square boxes) that update a single XML file (the rounded box). The XML file consists of several elements that describe the whole trip and a repeating group of individual TripDate elements something like this:
<?xml version="1.0" encoding="utf-8"?>
<Trip>
<TripName>Type the trip name here</TripName>
<TripDesc>Type the trip description here</TripDesc>
<TripStartDate>10/18/2008</TripStartDate>
<TripDates>
<TripDate
StayAt="Location"
Trans="Method"
Events="Event Description">10/18/2008</TripDate>
<TripDate
StayAt="Location"
Trans="Method"
Events="Event Description">10/19/2008</TripDate>
<TripDate
StayAt="Location"
Trans="Method"
Events="Event Description">10/20/2008</TripDate>
</TripDates>
</Trip>
To explain the application, each WPF form - MainWindow, TripDesc, and AddADay, will be explained separately along with the Visual Basic partial classes that make them work.

