Example 1-1. Minimal C# WPF application
// MyApp.cs
using System;
using System.Windows; // the root WPF namespace
namespace MyFirstAvalonApp {
class MyApp {
[STAThread]
static void Main( ) {
// the WPF message box
MessageBox.Show("Hello, Avalon");
}
}
}
1. Here, in project, you want to import the 3 framework DLLs in advance, respectively, Windowsbase,presentationcore, presentatioframework, so you can use the new system.windows --from \framework\v3.0 \windowsbase.dll, not \framework\v2.0.50727\system.windows.forms.dll, adds a lot of new features.
2. Note that vs2005 is not visible under Main, so play is not good; Find App.g.cs file, the main code is hidden here, change it accordingly. VS2005: Because the App class is a decentralized class, right-click the function definition to find two places, one is this page App.xaml.cs, and the other is directed to the App.g.cs file.
Example 1-3. A minimal msbuild project file
<!-- 1st.csproj -->
<Project
DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild
/2003">
<PropertyGroup>
<OutputType>winexe</OutputType>
<OutputPath>.\</OutputPath>
<Assembly>1st.exe</Assembly>
</PropertyGroup>
<ItemGroup>
<Compile Include="MyApp.cs" />
<Reference Include="System" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<Import Project="$(MsbuildBinPath)\Microsoft.CSharp.targets" />
</Project>