Let s look at the files necessary to create a simple navigation-based Hello World application. Later I ll describe the purpose and use of each file in detail.
First, you need to define the Application object. You do this in a file typically called the application definition file . This HelloWorldApplication.xaml file defines my Application object.
<NavigationApplication xmlns="http://schemas.microsoft.com/2003/xaml"
StartupUri="HelloWorld.xaml" />
This definition says, For my Application object, I want to use an instance of the MSAvalon.Windows.Navigation.NavigationApplication class. On startup, the application should navigate to and display the user interface (UI) defined in the HelloWorld.xaml file.
Here are the contents of the HelloWorld.xaml file. It s a slightly more interesting version of the previous Hello World example in Chapter 1.
<Border xmlns="http://schemas.microsoft.com/2003/xaml">
<FlowPanel>
<SimpleText Foreground="DarkRed" FontSize="14">Hello World!</SimpleText>
</FlowPanel>
</Border>
Now that I have all the code for my simple Hello World application, I need a project file that defines how to build my application. Here s my HelloWorld.proj file.
<Project DefaultTargets="Build">
<PropertyGroup>
<Property Language="C#" />
<Property DefaultClrNameSpace="IntroLonghorn" />
<Property TargetName="HelloWorld" />
</PropertyGroup>
<!--Imports the target which contains all the common targets-->
<Import Project="$(LAPI)\WindowsApplication.target" />
<ItemGroup>
<!-- Application markup -->
<Item Type="ApplicationDefinition" Include="HelloWorldApplication.xaml" />
<!-- Compiled Xaml Files list -->
<Item Type="Pages" Include="HelloWorld.xaml"/>
</ItemGroup>
</Project>
Put these three files in a directory. Open a Longhorn SDK command prompt, navigate to the directory containing your files, and run MSBuild. It will compile your program into an executable.
We ll examine the contents of the application definition file later in this chapter. In Chapter 3, I describe in detail many of the Extensible Application Markup Language (XAML) elements you can use to define a UI. Before we look at the project file in more depth, let s review some MSBuild terminology.